diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1c7130f..80b2095 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ version develop are flushed using Z_SYNC_FLUSH. + Switched to setuptools-scm for building the package rather than versioningit. + Test files are added to the source distribution. ++ Fix an issue where some tests failed because they ignored PYTHONPATH. version 0.5.1 ----------------- diff --git a/pyproject.toml b/pyproject.toml index 6446a22..531017a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ "Operating System :: Microsoft :: Windows", ] urls.homepage = "https://github.com/pycompression/python-zlib-ng" -urls.documentation = "python-zlib-ng.readthedocs.io" +urls.documentation = "https://python-zlib-ng.readthedocs.io" [tool.setuptools_scm] version_file = "src/zlib_ng/_version.py" diff --git a/tests/test_gzip_compliance.py b/tests/test_gzip_compliance.py index d938966..8ad5441 100644 --- a/tests/test_gzip_compliance.py +++ b/tests/test_gzip_compliance.py @@ -804,6 +804,19 @@ def test_decompress_stdin_stdout(self): self.assertEqual(err, b'') self.assertEqual(out, self.data) + # The following tests use assert_python_failure or assert_python_ok. + # + # If the env_vars argument to assert_python_failure or assert_python_ok + # is empty the test will run in isolated mode (-I) which means that the + # PYTHONPATH environment variable will be ignored and the test fails + # because the isal module can not be found, or the test is run usung the + # system installed version of the module instead of the newly built + # module that should be tested. + # + # By adding a dummy entry to the env_vars argument the isolated mode is + # not used and the PYTHONPATH environment variable is not ignored and + # the test works as expected. + @create_and_remove_directory(TEMPDIR) def test_decompress_infile_outfile(self): gzipname = os.path.join(TEMPDIR, 'testgzip.gz') @@ -812,7 +825,7 @@ def test_decompress_infile_outfile(self): with gzip.open(gzipname, mode='wb') as fp: fp.write(self.data) rc, out, err = assert_python_ok('-m', 'zlib_ng.gzip_ng', '-d', - gzipname) + gzipname, **{'_dummy': '1'}) with open(os.path.join(TEMPDIR, "testgzip"), "rb") as gunziped: self.assertEqual(gunziped.read(), self.data) @@ -824,7 +837,7 @@ def test_decompress_infile_outfile(self): def test_decompress_infile_outfile_error(self): rc, out, err = assert_python_failure('-m', 'zlib_ng.gzip_ng', '-d', - 'thisisatest.out') + 'thisisatest.out', **{'_dummy': '1'}) self.assertIn(b"filename doesn't end in .gz: 'thisisatest.out'", err.strip()) self.assertEqual(rc, 1) @@ -849,7 +862,7 @@ def test_compress_infile_outfile_default(self): fp.write(self.data) rc, out, err = assert_python_ok('-m', 'zlib_ng.gzip_ng', - local_testgzip) + local_testgzip, **{'_dummy': '1'}) self.assertTrue(os.path.exists(gzipname)) self.assertEqual(out, b'') @@ -867,7 +880,8 @@ def test_compress_infile_outfile(self): fp.write(self.data) rc, out, err = assert_python_ok('-m', 'zlib_ng.gzip_ng', - compress_level, local_testgzip) + compress_level, local_testgzip, + **{'_dummy': '1'}) self.assertTrue(os.path.exists(gzipname)) self.assertEqual(out, b'') @@ -877,7 +891,7 @@ def test_compress_infile_outfile(self): def test_compress_fast_best_are_exclusive(self): rc, out, err = assert_python_failure('-m', 'zlib_ng.gzip_ng', '--fast', - '--best') + '--best', **{'_dummy': '1'}) self.assertIn( b"error: argument -9/--best: not allowed with argument -1/--fast", err) @@ -885,7 +899,7 @@ def test_compress_fast_best_are_exclusive(self): def test_decompress_cannot_have_flags_compression(self): rc, out, err = assert_python_failure('-m', 'zlib_ng.gzip_ng', '--fast', - '-d') + '-d', **{'_dummy': '1'}) self.assertIn( b'error: argument -d/--decompress: not allowed with argument -1/--fast', err) diff --git a/tox.ini b/tox.ini index 06b7f91..14409e4 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,10 @@ commands = [testenv:asan] setenv= PYTHONDEVMODE=1 + PYTHONUNBUFFERED=1 PYTHONMALLOC=malloc - CFLAGS=-lasan -fsanitize=address -fno-omit-frame-pointer + CFLAGS=-lasan -fsanitize=address -fno-omit-frame-pointer -Og -g + ASAN_OPTIONS=log_path=asan_errors allowlist_externals=bash commands= bash -c 'export LD_PRELOAD=$(gcc -print-file-name=libasan.so) && printenv LD_PRELOAD && python -c "from zlib_ng import zlib_ng" && pytest tests'