From 4f8a26d6e6360f70de4e276441eb6c14344c48f9 Mon Sep 17 00:00:00 2001 From: thomasms Date: Wed, 28 Feb 2018 09:04:39 +0000 Subject: [PATCH] Moved tests out of package and fixes to pypi setup. --- .coveragerc | 2 +- .travis.yml | 2 +- pypact/tests/testsuite.py | 18 ------------------ pytest.ini | 2 +- setup.py | 11 ++++++++--- {pypact/tests => tests}/__init__.py | 0 {pypact/tests => tests}/output/__init__.py | 0 .../tests => tests}/output/baseoutputtest.py | 2 +- {pypact/tests => tests}/output/doseratetest.py | 4 +++- {pypact/tests => tests}/output/nuclidestest.py | 3 ++- {pypact/tests => tests}/output/outputtest.py | 7 ++++--- {pypact/tests => tests}/output/rundatatest.py | 3 ++- {pypact/tests => tests}/output/timesteptest.py | 7 ++++--- {pypact/tests => tests}/testerbase.py | 2 +- tests/testsuite.py | 18 ++++++++++++++++++ {pypact/tests => tests}/util/__init__.py | 0 {pypact/tests => tests}/util/filetest.py | 4 +++- {pypact/tests => tests}/util/linestest.py | 4 +++- {pypact/tests => tests}/util/numericaltest.py | 0 .../tests => tests}/util/propertyfindertest.py | 4 +++- update_on_pypi.sh | 6 ++++++ 21 files changed, 61 insertions(+), 38 deletions(-) delete mode 100644 pypact/tests/testsuite.py rename {pypact/tests => tests}/__init__.py (100%) rename {pypact/tests => tests}/output/__init__.py (100%) rename {pypact/tests => tests}/output/baseoutputtest.py (88%) rename {pypact/tests => tests}/output/doseratetest.py (99%) rename {pypact/tests => tests}/output/nuclidestest.py (99%) rename {pypact/tests => tests}/output/outputtest.py (88%) rename {pypact/tests => tests}/output/rundatatest.py (96%) rename {pypact/tests => tests}/output/timesteptest.py (96%) rename {pypact/tests => tests}/testerbase.py (95%) create mode 100644 tests/testsuite.py rename {pypact/tests => tests}/util/__init__.py (100%) rename {pypact/tests => tests}/util/filetest.py (97%) rename {pypact/tests => tests}/util/linestest.py (99%) rename {pypact/tests => tests}/util/numericaltest.py (100%) rename {pypact/tests => tests}/util/propertyfindertest.py (99%) create mode 100644 update_on_pypi.sh diff --git a/.coveragerc b/.coveragerc index 33a6be2..c712d25 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,2 @@ [run] -omit = pypact/tests/* +omit = tests/* diff --git a/.travis.yml b/.travis.yml index 17a2597..5bae936 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: script: - pip3 install -e $PYPACT - python $PYPACT/setup.py test - - coverage run $PYPACT/pypact/tests/testsuite.py + - coverage run $PYPACT/tests/testsuite.py - pylint -j4 $PYPACT/pypact --rcfile=$PYPACT/.pylintrc || true - fispactconverter.py $PYPACT/reference/test31.out test31.json # - diff test31.json $PYPACT/reference/test31.json diff --git a/pypact/tests/testsuite.py b/pypact/tests/testsuite.py deleted file mode 100644 index 759a1ec..0000000 --- a/pypact/tests/testsuite.py +++ /dev/null @@ -1,18 +0,0 @@ -import unittest - -from pypact.tests.util.filetest import FileUnitTest -from pypact.tests.util.linestest import LinesUnitTest -from pypact.tests.util.numericaltest import NumericalUnitTest -from pypact.tests.util.propertyfindertest import PropertyFinderUnitTest -from pypact.tests.output.doseratetest import DoseRateUnitTest -from pypact.tests.output.rundatatest import RunDataUnitTest -from pypact.tests.output.nuclidestest import NuclidesUnitTest -from pypact.tests.output.timesteptest import TimeStepUnitTest -from pypact.tests.output.outputtest import OutputUnitTest - -def main(): - unittest.TextTestRunner(verbosity=3).run(unittest.TestSuite()) - - -if __name__ == '__main__': - unittest.main() diff --git a/pytest.ini b/pytest.ini index 02d0f76..ffb7cbe 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] addopts = --cov-config .coveragerc --cov=./pypact -python_files = pypact/tests/testsuite.py +python_files = tests/testsuite.py diff --git a/setup.py b/setup.py index 70e95e8..36792c5 100644 --- a/setup.py +++ b/setup.py @@ -2,19 +2,24 @@ setup(name='pypact', - version='1.1.0', + version='1.1.1', description='The package for reading and manipulating the fispact output text file.', url='https://github.com/fispact/pypact', author='UKAEA', author_email='thomas.stainer@ukaea.uk', license='Apache License 2.0', packages=[ - 'pypact' + 'pypact', + 'pypact.analysis', + 'pypact.library', + 'pypact.output', + 'pypact.tools', + 'pypact.util' ], install_requires=[], python_requires='>=3', scripts=['pypact/tools/fispactconverter.py'], setup_requires=['pytest-runner'], - test_suite='pypact.tests.testsuite', + test_suite='tests.testsuite', tests_require=['pytest'], zip_safe=False) diff --git a/pypact/tests/__init__.py b/tests/__init__.py similarity index 100% rename from pypact/tests/__init__.py rename to tests/__init__.py diff --git a/pypact/tests/output/__init__.py b/tests/output/__init__.py similarity index 100% rename from pypact/tests/output/__init__.py rename to tests/output/__init__.py diff --git a/pypact/tests/output/baseoutputtest.py b/tests/output/baseoutputtest.py similarity index 88% rename from pypact/tests/output/baseoutputtest.py rename to tests/output/baseoutputtest.py index 6b46c51..61f350e 100644 --- a/pypact/tests/output/baseoutputtest.py +++ b/tests/output/baseoutputtest.py @@ -1,6 +1,6 @@ import os from pypact.filerecord import FileRecord -from pypact.tests.testerbase import Tester, REFERENCE_DIR +from tests.testerbase import Tester, REFERENCE_DIR class BaseOutputUnitTest(Tester): diff --git a/pypact/tests/output/doseratetest.py b/tests/output/doseratetest.py similarity index 99% rename from pypact/tests/output/doseratetest.py rename to tests/output/doseratetest.py index 9db4107..cc78bd4 100644 --- a/pypact/tests/output/doseratetest.py +++ b/tests/output/doseratetest.py @@ -1,7 +1,9 @@ import math + +from tests.output.baseoutputtest import BaseOutputUnitTest + from pypact.util.numerical import nan from pypact.filerecord import FileRecord -from pypact.tests.output.baseoutputtest import BaseOutputUnitTest from pypact.output.doserate import DoseRate diff --git a/pypact/tests/output/nuclidestest.py b/tests/output/nuclidestest.py similarity index 99% rename from pypact/tests/output/nuclidestest.py rename to tests/output/nuclidestest.py index 9e72e9d..a98facc 100644 --- a/pypact/tests/output/nuclidestest.py +++ b/tests/output/nuclidestest.py @@ -1,4 +1,5 @@ -from pypact.tests.output.baseoutputtest import BaseOutputUnitTest +from tests.output.baseoutputtest import BaseOutputUnitTest + from pypact.output.nuclides import Nuclides from pypact.output.nuclide import Nuclide diff --git a/pypact/tests/output/outputtest.py b/tests/output/outputtest.py similarity index 88% rename from pypact/tests/output/outputtest.py rename to tests/output/outputtest.py index 3e3550f..b6c91df 100644 --- a/pypact/tests/output/outputtest.py +++ b/tests/output/outputtest.py @@ -1,6 +1,7 @@ -from pypact.tests.output.baseoutputtest import BaseOutputUnitTest -from pypact.tests.output.rundatatest import RunDataAssertor -from pypact.tests.output.timesteptest import TimeStepAssertor +from tests.output.baseoutputtest import BaseOutputUnitTest +from tests.output.rundatatest import RunDataAssertor +from tests.output.timesteptest import TimeStepAssertor + from pypact.output.output import Output diff --git a/pypact/tests/output/rundatatest.py b/tests/output/rundatatest.py similarity index 96% rename from pypact/tests/output/rundatatest.py rename to tests/output/rundatatest.py index 914cc53..b778cd8 100644 --- a/pypact/tests/output/rundatatest.py +++ b/tests/output/rundatatest.py @@ -1,4 +1,5 @@ -from pypact.tests.output.baseoutputtest import BaseOutputUnitTest +from tests.output.baseoutputtest import BaseOutputUnitTest + from pypact.output.rundata import RunData diff --git a/pypact/tests/output/timesteptest.py b/tests/output/timesteptest.py similarity index 96% rename from pypact/tests/output/timesteptest.py rename to tests/output/timesteptest.py index 3f174ee..d162e93 100644 --- a/pypact/tests/output/timesteptest.py +++ b/tests/output/timesteptest.py @@ -1,6 +1,7 @@ -from pypact.tests.output.baseoutputtest import BaseOutputUnitTest -from pypact.tests.output.doseratetest import DoseRateAssertor -from pypact.tests.output.nuclidestest import NuclidesAssertor +from tests.output.baseoutputtest import BaseOutputUnitTest +from tests.output.doseratetest import DoseRateAssertor +from tests.output.nuclidestest import NuclidesAssertor + from pypact.output.timestep import TimeStep diff --git a/pypact/tests/testerbase.py b/tests/testerbase.py similarity index 95% rename from pypact/tests/testerbase.py rename to tests/testerbase.py index 782d55c..4e4505c 100644 --- a/pypact/tests/testerbase.py +++ b/tests/testerbase.py @@ -3,7 +3,7 @@ import os REFERENCE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), - '..', '..', 'reference') + '..', 'reference') class Tester(unittest.TestCase): diff --git a/tests/testsuite.py b/tests/testsuite.py new file mode 100644 index 0000000..09ce57f --- /dev/null +++ b/tests/testsuite.py @@ -0,0 +1,18 @@ +import unittest + +from tests.util.filetest import FileUnitTest +from tests.util.linestest import LinesUnitTest +from tests.util.numericaltest import NumericalUnitTest +from tests.util.propertyfindertest import PropertyFinderUnitTest +from tests.output.doseratetest import DoseRateUnitTest +from tests.output.rundatatest import RunDataUnitTest +from tests.output.nuclidestest import NuclidesUnitTest +from tests.output.timesteptest import TimeStepUnitTest +from tests.output.outputtest import OutputUnitTest + +def main(): + unittest.TextTestRunner(verbosity=3).run(unittest.TestSuite()) + + +if __name__ == '__main__': + unittest.main() diff --git a/pypact/tests/util/__init__.py b/tests/util/__init__.py similarity index 100% rename from pypact/tests/util/__init__.py rename to tests/util/__init__.py diff --git a/pypact/tests/util/filetest.py b/tests/util/filetest.py similarity index 97% rename from pypact/tests/util/filetest.py rename to tests/util/filetest.py index f57914a..88c369a 100644 --- a/pypact/tests/util/filetest.py +++ b/tests/util/filetest.py @@ -1,6 +1,8 @@ import unittest import os -from pypact.tests.testerbase import REFERENCE_DIR + +from tests.testerbase import REFERENCE_DIR + from pypact.util.file import * diff --git a/pypact/tests/util/linestest.py b/tests/util/linestest.py similarity index 99% rename from pypact/tests/util/linestest.py rename to tests/util/linestest.py index 504205f..6d188c9 100644 --- a/pypact/tests/util/linestest.py +++ b/tests/util/linestest.py @@ -1,5 +1,7 @@ import os -from pypact.tests.testerbase import Tester, REFERENCE_DIR + +from tests.testerbase import Tester, REFERENCE_DIR + import pypact.util.lines as lines from pypact.util.file import content_as_str diff --git a/pypact/tests/util/numericaltest.py b/tests/util/numericaltest.py similarity index 100% rename from pypact/tests/util/numericaltest.py rename to tests/util/numericaltest.py diff --git a/pypact/tests/util/propertyfindertest.py b/tests/util/propertyfindertest.py similarity index 99% rename from pypact/tests/util/propertyfindertest.py rename to tests/util/propertyfindertest.py index 6d2125e..7d1cd5f 100644 --- a/pypact/tests/util/propertyfindertest.py +++ b/tests/util/propertyfindertest.py @@ -1,5 +1,7 @@ import os -from pypact.tests.testerbase import Tester, REFERENCE_DIR + +from tests.testerbase import Tester, REFERENCE_DIR + import pypact.util.propertyfinder as pf from pypact.util.file import content_as_str diff --git a/update_on_pypi.sh b/update_on_pypi.sh new file mode 100644 index 0000000..c654eb8 --- /dev/null +++ b/update_on_pypi.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +python3 setup.py test +python3 setup.py sdist +python3 setup.py bdist_wheel +twine upload dist/*