dsoprea / PyEasyArchive

A very intuitive and useful adapter to libarchive for universal archive access.
MIT License
96 stars 33 forks source link

Using unittest instead of nose doesn't work #44

Closed paolostivanin closed 4 years ago

paolostivanin commented 4 years ago

As nose won't work with Python 3.9/3.10, I tried to use unittest instead, but some tests failed:

[    3s] test_enumerate_from_file (adapters.test_archive_read.TestArchiveRead) ... ok
[    3s] test_enumerate_from_memory (adapters.test_archive_read.TestArchiveRead) ... ok
[    3s] test_read_from_file (adapters.test_archive_read.TestArchiveRead) ... ok
[    3s] test_read_from_memory (adapters.test_archive_read.TestArchiveRead) ... ok
[    3s] test_read_symlinks (adapters.test_archive_read.TestArchiveRead) ... FAIL
[    3s] test_create_file (adapters.test_archive_write.TestArchiveWrite) ... ok
[    3s] test_create_file__unicode (adapters.test_archive_write.TestArchiveWrite) ... ok
[    3s] types.test_archive_entry (unittest.loader._FailedTest) ... ERROR
[    3s] 
[    3s] ======================================================================
[    3s] ERROR: types.test_archive_entry (unittest.loader._FailedTest)
[    3s] ----------------------------------------------------------------------
[    3s] ImportError: Failed to import test module: types.test_archive_entry
[    3s] Traceback (most recent call last):
[    3s]   File "/usr/lib64/python3.8/unittest/loader.py", line 436, in _find_test_path
[    3s]     module = self._get_module_from_name(name)
[    3s]   File "/usr/lib64/python3.8/unittest/loader.py", line 377, in _get_module_from_name
[    3s]     __import__(name)
[    3s] ModuleNotFoundError: No module named 'types.test_archive_entry'; 'types' is not a package
[    3s] 
[    3s] 
[    3s] ======================================================================
[    3s] FAIL: test_read_symlinks (adapters.test_archive_read.TestArchiveRead)
[    3s] ----------------------------------------------------------------------
[    3s] Traceback (most recent call last):
[    3s]   File "/home/abuild/rpmbuild/BUILD/libarchive-0.4.7/tests/adapters/test_archive_read.py", line 89, in test_read_symlinks
[    3s]     self.assertEqual(index, expected)
[    3s] AssertionError: {} != {'README.rst': 'libarchive/resources/README.rst'}
[    3s] - {}
[    3s] + {'README.rst': 'libarchive/resources/README.rst'}
[    3s] 
[    3s] ----------------------------------------------------------------------
[    3s] Ran 8 tests in 0.139s
[    3s] 
[    3s] FAILED (failures=1, errors=1)
dsoprea commented 4 years ago

I was unaware of nose being in the state that it's in. Haven't been to the website in a long time.

That's okay. Use nose2. It works fine.

https://github.com/dsoprea/PyEasyArchive/commit/61d3a708336496ed7021b98607cf7a0c4883b860

mcepl commented 4 years ago

@paolostivanin You are missing tests/__init__.py file.

With this patch anything (including python3 -munittest discover -v) works. It also replaces deprecated .assertEquals with supported .assertEqual.