From f3e1cb6d589747d3b9259660183f1affb1526521 Mon Sep 17 00:00:00 2001 From: Dan Blanchard Date: Wed, 7 Oct 2020 15:37:17 -0400 Subject: [PATCH] Remove all remnants of nose testing --- .travis.yml | 3 +- setup.cfg | 9 ++-- test-requirements.txt | 2 - test/streamparse/cli/test_jar.py | 19 +++----- test/streamparse/cli/test_kill.py | 19 +++----- test/streamparse/cli/test_list.py | 19 +++----- test/streamparse/cli/test_quickstart.py | 19 +++----- test/streamparse/cli/test_remove_logs.py | 19 +++----- test/streamparse/cli/test_run.py | 46 ++++++++----------- test/streamparse/cli/test_sparse.py | 23 ++++------ test/streamparse/cli/test_stats.py | 19 +++----- test/streamparse/cli/test_submit.py | 19 +++----- test/streamparse/cli/test_tail.py | 19 +++----- .../streamparse/cli/test_update_virtualenv.py | 19 +++----- test/streamparse/cli/test_worker_uptime.py | 19 +++----- tox.ini | 9 ++-- 16 files changed, 97 insertions(+), 185 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8181b647..4f9c283b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,7 @@ group: edge language: python sudo: false cache: - directories: - - $HOME/.cache/pip + pip: true python: - "3.6" - "3.7" diff --git a/setup.cfg b/setup.cfg index accca897..063493a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,5 @@ -[nosetests] -logging-clear-handlers = 1 -verbosity = 2 -detailed-errors = 1 +[bdist_wheel] +universal=1 + +[tool:pytest] +addopts = --doctest-modules --ignore=examples/ --ignore=doc/ --ignore=setup.py diff --git a/test-requirements.txt b/test-requirements.txt index dc2e14e2..42b30c5d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,2 @@ graphviz -mock; python_version < '3' -unittest2; python_version < '3' pytest \ No newline at end of file diff --git a/test/streamparse/cli/test_jar.py b/test/streamparse/cli/test_jar.py index bc137208..c3d87092 100644 --- a/test/streamparse/cli/test_jar.py +++ b/test/streamparse/cli/test_jar.py @@ -3,18 +3,11 @@ from streamparse.cli.jar import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class JARTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("jar" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "jar" in subcommands diff --git a/test/streamparse/cli/test_kill.py b/test/streamparse/cli/test_kill.py index a5196152..6823873b 100644 --- a/test/streamparse/cli/test_kill.py +++ b/test/streamparse/cli/test_kill.py @@ -3,18 +3,11 @@ from streamparse.cli.kill import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class KillTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("kill" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "kill" in subcommands diff --git a/test/streamparse/cli/test_list.py b/test/streamparse/cli/test_list.py index 7ee733e7..5d82214b 100644 --- a/test/streamparse/cli/test_list.py +++ b/test/streamparse/cli/test_list.py @@ -3,18 +3,11 @@ from streamparse.cli.list import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class ListTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("list" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "list" in subcommands diff --git a/test/streamparse/cli/test_quickstart.py b/test/streamparse/cli/test_quickstart.py index a5352bda..1d3dfad8 100644 --- a/test/streamparse/cli/test_quickstart.py +++ b/test/streamparse/cli/test_quickstart.py @@ -3,18 +3,11 @@ from streamparse.cli.quickstart import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class QuickStartTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("quickstart" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "quickstart" in subcommands diff --git a/test/streamparse/cli/test_remove_logs.py b/test/streamparse/cli/test_remove_logs.py index d49ac0a2..a899ac8f 100644 --- a/test/streamparse/cli/test_remove_logs.py +++ b/test/streamparse/cli/test_remove_logs.py @@ -3,18 +3,11 @@ from streamparse.cli.remove_logs import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class RemoveLogsTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("remove_logs" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "remove_logs" in subcommands diff --git a/test/streamparse/cli/test_run.py b/test/streamparse/cli/test_run.py index 90b1e480..c614e49d 100644 --- a/test/streamparse/cli/test_run.py +++ b/test/streamparse/cli/test_run.py @@ -2,37 +2,31 @@ import unittest from unittest.mock import patch -from nose.tools import ok_ - from streamparse.cli.run import main, subparser_hook -class RunTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("run" in subcommands) +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) - @patch("streamparse.cli.run.run_local_topology", autospec=True) - def test_main_args_passed(self, run_local_mock): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) + subcommands = parser._optionals._actions[1].choices.keys() + assert "run" in subcommands - args = parser.parse_args("run -e my_env -n my_topo --ackers 1".split()) - main(args) - run_local_mock.assert_called_with( - name="my_topo", - options={"topology.acker.executors": 1}, - env_name="my_env", - time=0, - config_file=None, - ) +@patch("streamparse.cli.run.run_local_topology", autospec=True) +def test_main_args_passed(run_local_mock): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) + args = parser.parse_args("run -e my_env -n my_topo --ackers 1".split()) -if __name__ == "__main__": - unittest.main() + main(args) + run_local_mock.assert_called_with( + name="my_topo", + options={"topology.acker.executors": 1}, + env_name="my_env", + time=0, + config_file=None, + ) diff --git a/test/streamparse/cli/test_sparse.py b/test/streamparse/cli/test_sparse.py index ee862172..49f314f1 100644 --- a/test/streamparse/cli/test_sparse.py +++ b/test/streamparse/cli/test_sparse.py @@ -3,19 +3,12 @@ from streamparse.cli import sparse -from nose.tools import ok_ - -class SparseTestCase(unittest.TestCase): - def test_load_subparsers(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - sparse.load_subparsers(subparsers) - # grab subcommands from subparsers - subcommands = parser._optionals._actions[1].choices.keys() - # we know quickstart will be a subcommand test others as needed - ok_("quickstart" in subcommands) - - -if __name__ == "__main__": - unittest.main() +def test_load_subparsers(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + sparse.load_subparsers(subparsers) + # grab subcommands from subparsers + subcommands = parser._optionals._actions[1].choices.keys() + # we know quickstart will be a subcommand test others as needed + assert "quickstart" in subcommands diff --git a/test/streamparse/cli/test_stats.py b/test/streamparse/cli/test_stats.py index e6a9cb41..25fcfe69 100644 --- a/test/streamparse/cli/test_stats.py +++ b/test/streamparse/cli/test_stats.py @@ -3,18 +3,11 @@ from streamparse.cli.stats import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class StatsTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("stats" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "stats" in subcommands diff --git a/test/streamparse/cli/test_submit.py b/test/streamparse/cli/test_submit.py index 3a9bdb0d..5dc747f8 100644 --- a/test/streamparse/cli/test_submit.py +++ b/test/streamparse/cli/test_submit.py @@ -3,18 +3,11 @@ from streamparse.cli.submit import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class SubmitTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("submit" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "submit" in subcommands diff --git a/test/streamparse/cli/test_tail.py b/test/streamparse/cli/test_tail.py index 7b381fcc..08e80a75 100644 --- a/test/streamparse/cli/test_tail.py +++ b/test/streamparse/cli/test_tail.py @@ -3,18 +3,11 @@ from streamparse.cli.tail import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class TailTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("tail" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "tail" in subcommands diff --git a/test/streamparse/cli/test_update_virtualenv.py b/test/streamparse/cli/test_update_virtualenv.py index b4d6ead4..a2fabcd8 100644 --- a/test/streamparse/cli/test_update_virtualenv.py +++ b/test/streamparse/cli/test_update_virtualenv.py @@ -3,18 +3,11 @@ from streamparse.cli.update_virtualenv import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class UpdateVirtualenvTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("update_virtualenv" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "update_virtualenv" in subcommands diff --git a/test/streamparse/cli/test_worker_uptime.py b/test/streamparse/cli/test_worker_uptime.py index d2c95a97..234639a7 100644 --- a/test/streamparse/cli/test_worker_uptime.py +++ b/test/streamparse/cli/test_worker_uptime.py @@ -3,18 +3,11 @@ from streamparse.cli.worker_uptime import subparser_hook -from nose.tools import ok_ +def test_subparser_hook(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + subparser_hook(subparsers) -class WorkerUptimeTestCase(unittest.TestCase): - def test_subparser_hook(self): - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() - subparser_hook(subparsers) - - subcommands = parser._optionals._actions[1].choices.keys() - ok_("worker_uptime" in subcommands) - - -if __name__ == "__main__": - unittest.main() + subcommands = parser._optionals._actions[1].choices.keys() + assert "worker_uptime" in subcommands diff --git a/tox.ini b/tox.ini index c80efa23..5ce467be 100644 --- a/tox.ini +++ b/tox.ini @@ -4,14 +4,11 @@ # and then run "tox" from this directory. [tox] -envlist = py27, py33, py34, pypy +envlist = py36, py37, py38, py39, pypy3 [testenv] -deps = +deps = -rrequirements.txt -rtest-requirements.txt -commands = nosetests -v --logging-level=DEBUG +commands = py.test -v --logging-level=DEBUG -[testenv:flake8] -deps = flake8 -commands = flake8 streamparse test \ No newline at end of file