From 97f11ab719e71ecb8dc960843e2dbb7502dc0154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek?= Date: Wed, 4 May 2022 10:52:07 +0200 Subject: [PATCH] Simple test, sample data generation script and more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Václav Valíček --- .coveragerc | 12 ++++++++++++ .gitignore | 8 +++++++- .laminar | 1 + ci/docker/run-tests | 3 --- tests/_support_data/gen-data.sh | 2 ++ tests/test_abcd.py | 24 ++++++++++++++++++++++++ 6 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .coveragerc create mode 100755 tests/_support_data/gen-data.sh create mode 100644 tests/test_abcd.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..42a3f3b --- /dev/null +++ b/.coveragerc @@ -0,0 +1,12 @@ +[run] +omit = + tests/* + + + +[report] +exclude_lines = + if __name__ == .__main__.: + except ModuleNotFoundError: + + diff --git a/.gitignore b/.gitignore index a391afd..c948f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ *.swp -.idea/workspace.xml venv/ +dvenv/ +.idea/workspace.xml +__pycache__/ +.coverage +build/ +dist/ +htmlcov/ diff --git a/.laminar b/.laminar index d484957..972f3e1 100755 --- a/.laminar +++ b/.laminar @@ -119,3 +119,4 @@ cat $scratch/sum | column -t exit $MAX_EXIT +h \ No newline at end of file diff --git a/ci/docker/run-tests b/ci/docker/run-tests index e3d57b5..81b1fd9 100755 --- a/ci/docker/run-tests +++ b/ci/docker/run-tests @@ -30,9 +30,6 @@ wraperr pip install -r requirements.txt status "Installing dev dependencies" wraperr pip install -r requirements.dev.txt -# TODO: fix later -exit 0 - status "Preparing data trees for tests..." wraperr bash -c "cd tests/_support_data; ./gen-data.sh" diff --git a/tests/_support_data/gen-data.sh b/tests/_support_data/gen-data.sh new file mode 100755 index 0000000..5211726 --- /dev/null +++ b/tests/_support_data/gen-data.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo TODO: add some support data diff --git a/tests/test_abcd.py b/tests/test_abcd.py new file mode 100644 index 0000000..e023706 --- /dev/null +++ b/tests/test_abcd.py @@ -0,0 +1,24 @@ +import unittest + + +class TestStringMethods(unittest.TestCase): + + def test_upper(self): + self.assertEqual('foo'.upper(), 'FOO') + + def test_isupper(self): + self.assertTrue('FOO'.isupper()) + self.assertFalse('Foo'.isupper()) + + def test_split(self): + s = 'hello world' + self.assertEqual(s.split(), ['hello', 'world']) + # check that s.split fails when the separator is not a string + with self.assertRaises(TypeError): + s.split(2) + + + +if __name__ == '__main__': + unittest.main() +