diff --git a/db_eplusout_reader/db_esofile.py b/db_eplusout_reader/db_esofile.py index 6e82886..bc8c848 100644 --- a/db_eplusout_reader/db_esofile.py +++ b/db_eplusout_reader/db_esofile.py @@ -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.""" @@ -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.""" diff --git a/tests/test_eso_file.py b/tests/test_eso_file.py index ce434aa..d21c2b7 100644 --- a/tests/test_eso_file.py +++ b/tests/test_eso_file.py @@ -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] @@ -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