Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase test strictness: make test warnings into errors #185

Merged
merged 8 commits into from
Jan 23, 2024
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
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
# convert warnings to errors, except for ImportWarnings in numpy (needed for pp38)
# FIXME: eventually we should be able to remove the numpy exception
filterwarnings = ["error", "default::ImportWarning"]
log_cli_level = "info"
testpaths = [
"tests",
]

[tool.cibuildwheel]
skip = ["*-win32", "*_i686", # skip 32-bit builds
"pp37-*", "pp310-*", # skip certain PyPy configurations
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def path_to_src(source_path_list):
url = "http://www.pypop.org/",
project_urls={
'Documentation': 'http://pypop.org/docs/',
'Changelog': 'https://github.com/alexlancaster/pypop/blob/main/NEWS.rst',
'Changelog': 'https://github.com/alexlancaster/pypop/blob/main/NEWS.md',
'Source': 'https://github.com/alexlancaster/pypop/',
'Tracker': 'https://github.com/alexlancaster/pypop/issues',
},
Expand Down
4 changes: 2 additions & 2 deletions src/PyPop/ParseFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def _sampleFileRead(self, filename):

*For internal use only*.
"""
f = open(filename, 'r')
self.fileData = f.readlines()
with open(filename, 'r') as f:
self.fileData = f.readlines()

def _mapPopHeaders(self):

Expand Down
3 changes: 2 additions & 1 deletion tests/test_100k_Emhaplofreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ def test_100k_Emhaplofreq():
assert exit_code == 0
# compare with md5sum of output file
# FIXME: disable for the moment
# assert hashlib.md5(open("Test_100k_20loci_Dataset-out.txt", 'rb').read()).hexdigest() == 'd899396e90d99ad9eb2002506e699091'
# with open("Test_100k_20loci_Dataset-out.txt", 'rb') as out_handle:
# assert hashlib.md5(out_handle.read()).hexdigest() == 'd899396e90d99ad9eb2002506e699091'

6 changes: 4 additions & 2 deletions tests/test_AlleleColon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ def test_AlleleColon_HardyWeinberg():
# check exit code
assert exit_code == 0
# compare with md5sum of output file
assert hashlib.md5(open("Test_Allele_Colon_HardyWeinberg-out.txt", 'rb').read()).hexdigest() == '245a8a8493506c0b65ba9a3469173b13'
with open("Test_Allele_Colon_HardyWeinberg-out.txt", 'rb') as out_handle:
assert hashlib.md5(out_handle.read()).hexdigest() == '245a8a8493506c0b65ba9a3469173b13'

def test_AlleleColon_Emhaplofreq():
exit_code = run_pypop_process('./tests/data/Test_Allele_Colon_Emhaplofreq.ini', './tests/data/Test_Allele_Colon_Emhaplofreq.pop')
# check exit code
assert exit_code == 0
# compare with md5sum of output file
assert hashlib.md5(open("Test_Allele_Colon_Emhaplofreq-out.txt", 'rb').read()).hexdigest() == 'dc9b6530a8d85e0d4cf86cecf6b0a9c9'
with open("Test_Allele_Colon_Emhaplofreq-out.txt", 'rb') as out_handle:
assert hashlib.md5(out_handle.read()).hexdigest() == 'dc9b6530a8d85e0d4cf86cecf6b0a9c9'
6 changes: 4 additions & 2 deletions tests/test_GenotypeCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ def test_GenotypeCommon_HardyWeinberg():
# check exit code
assert exit_code == 0
# compare with md5sum of output file
assert hashlib.md5(open("BIGDAWG_SynthControl_Data-out.txt", 'rb').read()).hexdigest() == 'db4bc1113e9eab337561f7510e73381f'
with open("BIGDAWG_SynthControl_Data-out.txt", 'rb') as out_handle:
assert hashlib.md5(out_handle.read()).hexdigest() == 'db4bc1113e9eab337561f7510e73381f'

def test_GenotypeCommonDash_HardyWeinberg():
exit_code = run_pypop_process('./tests/data/WS_BDCtrl_Test_HW.ini', './tests/data/BIGDAWG_SynthControl_Data_dash.pop')
# check exit code
assert exit_code == 0
# compare with md5sum of output file
assert hashlib.md5(open("BIGDAWG_SynthControl_Data_dash-out.txt", 'rb').read()).hexdigest() == '36053392f9dd25c9a2a6bb1fc6db242a'
with open("BIGDAWG_SynthControl_Data_dash-out.txt", 'rb') as out_handle:
assert hashlib.md5(out_handle.read()).hexdigest() == '36053392f9dd25c9a2a6bb1fc6db242a'