Skip to content

Commit

Permalink
Drop legacy test runner script
Browse files Browse the repository at this point in the history
Henceforth pytest shall be the only supported way of running pyspacewar
tests.
  • Loading branch information
mgedmin committed Dec 31, 2022
1 parent 81f2f75 commit ecf41a7
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 138 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,6 +1,5 @@
include MANIFEST.in
include benchmark.py
include test.py
include pyspacewar.pyw
include *.txt
include *.rst
Expand Down
4 changes: 0 additions & 4 deletions pytest.ini
@@ -1,6 +1,2 @@
[pytest]
addopts = --doctest-modules --doctest-report only_first_failure --doctest-report ndiff
# the default is 'test*', but we want to exclude test_suite. glob patterns
# don't have negative lookahead assertions, do they? *sigh*
# well we don't have any top-level test functions anyway, can we exclude everything?
python_functions =
17 changes: 0 additions & 17 deletions src/pyspacewar/tests/test_ai.py
@@ -1,10 +1,5 @@
#!/usr/bin/env python

import doctest
import os
import sys
import unittest


def effect(msg):
def callback(*args):
Expand Down Expand Up @@ -233,15 +228,3 @@ def doctest_AIController_maybe_fire():
>>> ai.maybe_fire(enemy, 10)
"""


def test_suite():
path = os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', '..'))
if path not in sys.path:
sys.path.append(path)
return doctest.DocTestSuite()


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
17 changes: 0 additions & 17 deletions src/pyspacewar/tests/test_game.py
@@ -1,10 +1,5 @@
#!/usr/bin/env python

import doctest
import os
import sys
import unittest


class TimeSourceStub(object):

Expand Down Expand Up @@ -310,15 +305,3 @@ def doctest_Game_new():
2
"""


def test_suite():
path = os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', '..'))
if path not in sys.path:
sys.path.append(path)
return doctest.DocTestSuite()


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
17 changes: 1 addition & 16 deletions src/pyspacewar/tests/test_main.py
@@ -1,9 +1,6 @@
#!/usr/bin/env python

import doctest
import os
import sys
import unittest

import pytest

Expand Down Expand Up @@ -48,18 +45,6 @@ def doctest_main():


@pytest.fixture(scope='module', autouse=True)
def setUp(test=None):
def fake_game_ui(test=None):
from pyspacewar import main
main.GameUI = FakeGameUI


def test_suite():
path = os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', '..'))
if path not in sys.path:
sys.path.append(path)
return doctest.DocTestSuite(setUp=setUp)


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
38 changes: 2 additions & 36 deletions src/pyspacewar/tests/test_ui.py
@@ -1,12 +1,9 @@
#!/usr/bin/env python
from __future__ import print_function

import doctest
import os
import shutil
import sys
import tempfile
import unittest

import mock
import pygame
Expand Down Expand Up @@ -3066,15 +3063,7 @@ def doctest_GameUI_wait_for_tick():


@pytest.fixture(autouse=True)
def _pytest_setup(doctest_namespace):
fake_test = mock.Mock()
fake_test.globs = doctest_namespace
setUp(fake_test)
yield
tearDown(fake_test)


def setUp(test):
def pytest_setup():
os.environ['SDL_VIDEODRIVER'] = 'dummy'
os.environ['SDL_AUDIODRIVER'] = 'dummy'
pygame.init() # so that pygame.key.name() works
Expand All @@ -3086,28 +3075,5 @@ def setUp(test):
pygame.Surface = SurfaceStub
pygame.surfarray.array_alpha = array_alpha_stub
pygame.surfarray.pixels_alpha = pixels_alpha_stub


def tearDown(test):
yield
mock.patch.stopall()


def test_suite():
path = os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', '..'))
if path not in sys.path:
sys.path.append(path)
optionflags = (
doctest.REPORT_ONLY_FIRST_FAILURE
| doctest.REPORT_NDIFF
)
return unittest.TestSuite([
doctest.DocTestSuite('pyspacewar.ui', optionflags=optionflags,
setUp=setUp, tearDown=tearDown),
doctest.DocTestSuite(optionflags=optionflags,
setUp=setUp, tearDown=tearDown),
])


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
20 changes: 0 additions & 20 deletions src/pyspacewar/tests/test_world.py
@@ -1,11 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function

import doctest
import os
import sys
import unittest


class Object(object):

Expand Down Expand Up @@ -753,18 +748,3 @@ def doctest_Planet():
>>> moon.collision(sun) # nothing happens
"""


def test_suite():
path = os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', '..'))
if path not in sys.path:
sys.path.append(path)
return unittest.TestSuite([
doctest.DocTestSuite('pyspacewar.world'),
doctest.DocTestSuite(),
])


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
25 changes: 0 additions & 25 deletions test.py

This file was deleted.

4 changes: 2 additions & 2 deletions tox.ini
Expand Up @@ -33,12 +33,12 @@ commands = {[testenv:coverage]commands}
[testenv:flake8]
deps = flake8
skip_install = true
commands = flake8 conftest.py setup.py test.py src
commands = flake8 conftest.py setup.py src

[testenv:isort]
deps = isort
skip_install = true
commands = isort {posargs: -c --diff benchmark.py conftest.py setup.py test.py src}
commands = isort {posargs: -c --diff benchmark.py conftest.py setup.py src}

[testenv:check-manifest]
deps = check-manifest
Expand Down

0 comments on commit ecf41a7

Please sign in to comment.