From 36f0c0fe0ba563cce023c785b677df62342856b7 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 12 Sep 2022 23:54:42 -0400 Subject: [PATCH] add github actions for tests (#17) --- .github/workflows/test.yml | 19 +++++++++++++++++++ tests/__init__.py | 0 tests/dpmdargs.py | 4 ++-- tests/test_checker.py | 2 +- tests/test_creation.py | 2 +- tests/test_docgen.py | 4 ++-- tests/test_normalizer.py | 4 ++-- 7 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 tests/__init__.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c88ba61 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Python package + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3 + - run: pip install .[test] coverage + - name: Test + run: coverage run --source=./dargs -m unittest -v && coverage report + - uses: codecov/codecov-action@v3 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/dpmdargs.py b/tests/dpmdargs.py index 26f87ad..ed03c19 100644 --- a/tests/dpmdargs.py +++ b/tests/dpmdargs.py @@ -1,4 +1,4 @@ -from context import dargs +from .context import dargs from dargs import dargs, Argument, Variant ACTIVATION_FN_DICT = { @@ -615,4 +615,4 @@ def normalize(data): if __name__ == "__main__": import json data = json.loads(example_json_str) - normalize(data) \ No newline at end of file + normalize(data) diff --git a/tests/test_checker.py b/tests/test_checker.py index bff457b..7968a30 100644 --- a/tests/test_checker.py +++ b/tests/test_checker.py @@ -1,4 +1,4 @@ -from context import dargs +from .context import dargs import unittest from dargs import Argument, Variant from dargs.dargs import ArgumentKeyError, ArgumentTypeError, ArgumentValueError diff --git a/tests/test_creation.py b/tests/test_creation.py index 36dc6b0..d921c26 100644 --- a/tests/test_creation.py +++ b/tests/test_creation.py @@ -1,4 +1,4 @@ -from context import dargs +from .context import dargs import unittest from dargs import Argument, Variant diff --git a/tests/test_docgen.py b/tests/test_docgen.py index e5653d3..f033a23 100644 --- a/tests/test_docgen.py +++ b/tests/test_docgen.py @@ -1,4 +1,4 @@ -from context import dargs +from .context import dargs import unittest import json from dargs import Argument, Variant, ArgumentEncoder @@ -119,7 +119,7 @@ def test_multi_variants(self): def test_dpmd(self): from dargs import dargs - from dpmdargs import gen_doc + from .dpmdargs import gen_doc dargs.RAW_ANCHOR = False docstr = gen_doc(make_anchor=True, make_link=True) # print("\n\n"+docstr) diff --git a/tests/test_normalizer.py b/tests/test_normalizer.py index dc9f3c4..3d40f74 100644 --- a/tests/test_normalizer.py +++ b/tests/test_normalizer.py @@ -1,4 +1,4 @@ -from context import dargs +from .context import dargs import unittest from dargs import Argument, Variant @@ -118,7 +118,7 @@ def test_complicated(self): def test_dpmd(self): import json - from dpmdargs import normalize, example_json_str + from .dpmdargs import normalize, example_json_str data = json.loads(example_json_str) normalize(data)