From 4d66b4667c3edd5fc898f20898ea8847f6490866 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 13 Jul 2010 11:10:45 +0200 Subject: [PATCH] Moved from nose to py.test (the former doesn't officially support py3k, which is limiting). --- README | 2 +- core/tests/app_test.py | 3 +-- core/tests/conftest.py | 28 ++++++++++++++++++++++++++++ core/tests/directories_test.py | 3 +-- core/tests/engine_test.py | 3 +-- core/tests/ignore_test.py | 2 +- core/tests/results_test.py | 2 +- core/tests/scanner_test.py | 2 +- core_me/tests/conftest.py | 28 ++++++++++++++++++++++++++++ core_pe/tests/conftest.py | 28 ++++++++++++++++++++++++++++ core_se/tests/conftest.py | 28 ++++++++++++++++++++++++++++ core_se/tests/fs_test.py | 3 +-- 12 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 core/tests/conftest.py create mode 100644 core_me/tests/conftest.py create mode 100644 core_pe/tests/conftest.py create mode 100644 core_se/tests/conftest.py diff --git a/README b/README index b5c0eaaf..0d6a62f2 100644 --- a/README +++ b/README @@ -32,7 +32,7 @@ General dependencies - lxml, to read and write XML files. (http://codespeak.net/lxml/) - Mako, to generate help files. (http://www.makotemplates.org/) - PyYaml, for help files and the build system. (http://pyyaml.org/) -- Nose, to run unit tests. (http://somethingaboutorange.com/mrl/projects/nose/) +- py.test, to run unit tests. (http://codespeak.net/py/dist/test/) OS X prerequisites ----- diff --git a/core/tests/app_test.py b/core/tests/app_test.py index 6a1ffbc0..c09fbd98 100644 --- a/core/tests/app_test.py +++ b/core/tests/app_test.py @@ -9,8 +9,7 @@ import os import logging -from nose.tools import eq_ - +from hsutil.testutil import eq_ from hsutil.testcase import TestCase from hsutil import io from hsutil.path import Path diff --git a/core/tests/conftest.py b/core/tests/conftest.py new file mode 100644 index 00000000..7acadad4 --- /dev/null +++ b/core/tests/conftest.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Created By: Virgil Dupras +# Created On: 2010-07-11 +# Copyright 2010 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "BSD" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/bsd_license + +# This unit is required to make tests work with py.test. When running + +import py + +def get_testunit(item): + if hasattr(item, 'obj'): + testunit = py.builtin._getimself(item.obj) + if hasattr(testunit, 'global_setup'): + return testunit + +def pytest_runtest_setup(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_setup() + +def pytest_runtest_teardown(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_teardown() diff --git a/core/tests/directories_test.py b/core/tests/directories_test.py index 55fcf33e..cd34b6bc 100644 --- a/core/tests/directories_test.py +++ b/core/tests/directories_test.py @@ -10,10 +10,9 @@ import os.path as op import os import time -from nose.tools import eq_ - from hsutil import io from hsutil.path import Path +from hsutil.testutil import eq_ from hsutil.testcase import TestCase from ..directories import * diff --git a/core/tests/engine_test.py b/core/tests/engine_test.py index 450cca1e..0d227e32 100644 --- a/core/tests/engine_test.py +++ b/core/tests/engine_test.py @@ -8,11 +8,10 @@ import sys -from nose.tools import eq_ - from hscommon import job from hsutil.decorators import log_calls from hsutil.misc import first +from hsutil.testutil import eq_ from hsutil.testcase import TestCase from .. import engine diff --git a/core/tests/ignore_test.py b/core/tests/ignore_test.py index 4054a9cf..dd3bf569 100644 --- a/core/tests/ignore_test.py +++ b/core/tests/ignore_test.py @@ -9,7 +9,7 @@ import cStringIO from lxml import etree -from nose.tools import eq_ +from hsutil.testutil import eq_ from ..ignore import * diff --git a/core/tests/results_test.py b/core/tests/results_test.py index 2df0bcaa..cdc682e7 100644 --- a/core/tests/results_test.py +++ b/core/tests/results_test.py @@ -11,9 +11,9 @@ import StringIO import os.path as op from lxml import etree -from nose.tools import eq_ from hsutil.path import Path +from hsutil.testutil import eq_ from hsutil.testcase import TestCase from hsutil.misc import first diff --git a/core/tests/scanner_test.py b/core/tests/scanner_test.py index 8b44aff2..a33b3c19 100644 --- a/core/tests/scanner_test.py +++ b/core/tests/scanner_test.py @@ -6,11 +6,11 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/hs_license -from nose.tools import eq_ from hscommon import job from hsutil import io from hsutil.path import Path +from hsutil.testutil import eq_ from hsutil.testcase import TestCase from .. import fs diff --git a/core_me/tests/conftest.py b/core_me/tests/conftest.py new file mode 100644 index 00000000..7acadad4 --- /dev/null +++ b/core_me/tests/conftest.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Created By: Virgil Dupras +# Created On: 2010-07-11 +# Copyright 2010 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "BSD" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/bsd_license + +# This unit is required to make tests work with py.test. When running + +import py + +def get_testunit(item): + if hasattr(item, 'obj'): + testunit = py.builtin._getimself(item.obj) + if hasattr(testunit, 'global_setup'): + return testunit + +def pytest_runtest_setup(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_setup() + +def pytest_runtest_teardown(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_teardown() diff --git a/core_pe/tests/conftest.py b/core_pe/tests/conftest.py new file mode 100644 index 00000000..7acadad4 --- /dev/null +++ b/core_pe/tests/conftest.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Created By: Virgil Dupras +# Created On: 2010-07-11 +# Copyright 2010 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "BSD" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/bsd_license + +# This unit is required to make tests work with py.test. When running + +import py + +def get_testunit(item): + if hasattr(item, 'obj'): + testunit = py.builtin._getimself(item.obj) + if hasattr(testunit, 'global_setup'): + return testunit + +def pytest_runtest_setup(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_setup() + +def pytest_runtest_teardown(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_teardown() diff --git a/core_se/tests/conftest.py b/core_se/tests/conftest.py new file mode 100644 index 00000000..7acadad4 --- /dev/null +++ b/core_se/tests/conftest.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Created By: Virgil Dupras +# Created On: 2010-07-11 +# Copyright 2010 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "BSD" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/bsd_license + +# This unit is required to make tests work with py.test. When running + +import py + +def get_testunit(item): + if hasattr(item, 'obj'): + testunit = py.builtin._getimself(item.obj) + if hasattr(testunit, 'global_setup'): + return testunit + +def pytest_runtest_setup(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_setup() + +def pytest_runtest_teardown(item): + testunit = get_testunit(item) + if testunit is not None: + testunit.global_teardown() diff --git a/core_se/tests/fs_test.py b/core_se/tests/fs_test.py index 30e19ca8..d2d0d6f4 100644 --- a/core_se/tests/fs_test.py +++ b/core_se/tests/fs_test.py @@ -9,9 +9,8 @@ import hashlib -from nose.tools import eq_ - from hsutil.testcase import TestCase +from hsutil.testutil import eq_ from core.fs import File from core.tests.directories_test import create_fake_fs