From 3ed6d743e6dd5bb90db16c0086ee7e05a84cc3b5 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Thu, 13 Jan 2022 14:26:30 -0800 Subject: [PATCH] Switch to pytests, add a tiny bit of smoke test coverage to get something coverage no longer gets --- pytest.ini | 4 ++++ requirements-dev.txt | 11 ++--------- script/coverage | 4 +++- script/test | 4 +++- setup.py | 4 ++++ tests/test_octodns_record.py | 6 ++++++ 6 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..6c15b71 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +filterwarnings = + # ovh has apparently vendored an old requests version that hits warnings :-/, it'll go away/move soon enough + ignore::DeprecationWarning:ovh.*: diff --git a/requirements-dev.txt b/requirements-dev.txt index 59041bb..2331aad 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,17 +1,10 @@ build==0.7.0 coverage mock -nose -nose-no-network -nose-timer pycodestyle==2.6.0 pyflakes==2.2.0 +pytest +pytest-network readme_renderer[md]==26.0 requests_mock twine==3.4.2 - -# Profiling tests... -# nose-cprof -# snakeviz -# ./script/test --with-cprof --cprofile-stats-erase -# snakeviz stats.dat diff --git a/script/coverage b/script/coverage index 2ca8d4b..b44c84c 100755 --- a/script/coverage +++ b/script/coverage @@ -36,7 +36,9 @@ grep -r -I --line-number "# pragma: +no.*cover" octodns && { exit 1 } -coverage run --branch --source=octodns --omit=octodns/cmds/* "$(command -v nosetests)" --with-no-network --with-xunit "$@" +export PYTHONPATH=.:$PYTHONPATH + +coverage run --branch --source=octodns --omit=octodns/cmds/* "$(command -v pytest)" --disable-network "$@" coverage html coverage xml coverage report --show-missing diff --git a/script/test b/script/test index b074595..7015111 100755 --- a/script/test +++ b/script/test @@ -30,4 +30,6 @@ export ARM_CLIENT_SECRET= export ARM_TENANT_ID= export ARM_SUBSCRIPTION_ID= -nosetests --with-no-network "$@" +export PYTHONPATH=.:$PYTHONPATH + +pytest --disable-network "$@" diff --git a/setup.py b/setup.py index c256ec5..2560c0b 100644 --- a/setup.py +++ b/setup.py @@ -80,4 +80,8 @@ setup( python_requires='>=3.6', url='https://github.com/octodns/octodns', version=octodns.__VERSION__, + tests_require=( + 'pytest', + 'pytest-network', + ), ) diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index f729118..73505e6 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -3459,6 +3459,12 @@ class TestDynamicRecords(TestCase): self.assertTrue(rules) self.assertEqual(a_data['dynamic']['rules'][0], rules[0].data) + # smoke test of _DynamicMixin.__repr__ + a.__repr__() + delattr(a, 'values') + a.value = 'abc' + a.__repr__() + def test_simple_aaaa_weighted(self): aaaa_data = { 'dynamic': {