Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions db_eplusout_reader/db_esofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def append(self, item):

def count(self):
"""Return the number of DBEsoFile objects in the collection."""
len(self._db_eso_files)
return len(self._db_eso_files)

def index(self, item):
"""Return the index of the given DBEsoFile in the collection."""
Expand All @@ -308,7 +308,7 @@ def remove(self, item):

def reverse(self):
"""Reverse the order of the collection in place."""
reversed(self._db_eso_files)
self._db_eso_files.reverse()

def sort(self, reverse):
"""Sort the collection in place by file name."""
Expand Down
18 changes: 8 additions & 10 deletions tests/test_eso_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ def test_append(self, session_eso_file):
col.append(session_eso_file)
assert col[0] is session_eso_file

def test_count_returns_none(self, session_eso_file):
# count() is missing a return statement — it currently returns None
col = DBEsoFileCollection([session_eso_file])
assert col.count() is None
def test_count(self, session_eso_file):
col = DBEsoFileCollection([session_eso_file, session_eso_file])
assert col.count() == 2

def test_index(self, session_eso_file_collection):
item = session_eso_file_collection[0]
Expand All @@ -190,13 +189,12 @@ def test_remove(self, session_eso_file):
col.remove(session_eso_file)
assert len(list(col)) == 0

def test_reverse_does_not_mutate(self, session_eso_file):
# reverse() calls reversed() but doesn't assign the result back —
# the list remains unchanged (known bug)
col = DBEsoFileCollection([session_eso_file, session_eso_file])
original_first = col[0]
def test_reverse(self, session_eso_file_collection):
first, second = session_eso_file_collection[0], session_eso_file_collection[1]
col = DBEsoFileCollection([first, second])
col.reverse()
assert col[0] is original_first # unchanged
assert col[0] is second
assert col[1] is first

def test_sort_raises_attribute_error(self, session_eso_file):
# sort() references ef.file_name which does not exist on DBEsoFile
Expand Down
Loading