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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 20 additions & 6 deletions tests/test_gzip_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo here. "usung" → "using".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I also see a copy paste error with "isal". That should be zlib_ng.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 34c171b

# 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')
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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'')
Expand All @@ -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'')
Expand All @@ -877,15 +891,15 @@ 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)
self.assertEqual(out, b'')

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)
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading