Commit 1b428db1 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Remove dependency on nosetest

parent 3b0a607b
Pipeline #1005 passed with stages
in 33 seconds
......@@ -33,7 +33,7 @@ test:
allow_failure: true
script:
- apt-get update && apt-get install -y -qq graphviz
- pip install nose pytest llbase
- pip install pytest llbase pydot
- pytest --junitxml=pytest_report.xml
artifacts:
when: always
......
......@@ -44,7 +44,7 @@ except ImportError:
# will fail. But we don't want a spurious test failure showing up; just skip
# that test.
try:
from nose.plugins.skip import SkipTest
from unittest import SkipTest
except ImportError:
# whoops, user machine, it's a real problem: use real ImportError
SkipTest = ImportError
......
......@@ -27,7 +27,6 @@ import logging
import pprint
import tempfile
import unittest
from nose.tools import * # assert_equals
from .baseline_compare import AutobuildBaselineCompare
from autobuild import autobuild_tool_build as build
import autobuild.configfile as configfile
......@@ -124,7 +123,7 @@ class TestBuild(LocalBase):
metadata = self.read_metadata()
assert not metadata.package_description.version_file, \
"version_file erroneously propagated into metadata"
assert_equal(metadata.package_description.version, "1.0")
self.assertEqual(metadata.package_description.version, "1.0")
def test_autobuild_build_all(self):
self.autobuild('build', '--config-file=' + self.tmp_file, '--id=123456', '-a')
......@@ -235,7 +234,7 @@ class TestVersionFileOddWhitespace(LocalBase):
def test_autobuild_build(self):
build('build', '--config-file=' + self.tmp_file, '--id=123456')
assert_equal(self.read_metadata().package_description.version, "2.3")
self.assertEqual(self.read_metadata().package_description.version, "2.3")
class TestSubstitutions(LocalBase):
def get_config(self):
......
......@@ -41,7 +41,6 @@ from autobuild.autobuild_main import Autobuild
from .baseline_compare import AutobuildBaselineCompare
from autobuild.autobuild_tool_edit import AutobuildTool
from .basetest import BaseTest
from nose.tools import * # assert_equal() et al.
class TestEdit(BaseTest, AutobuildBaselineCompare):
......@@ -68,7 +67,7 @@ class TestEdit(BaseTest, AutobuildBaselineCompare):
args = ['build', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethis']
expected_config = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'build': {'command': 'makethis'}, 'name': 'newbuild'}}}}}, 'version': configfile.AUTOBUILD_CONFIG_VERSION, 'type': 'autobuild'}
built_config = self._try_cmd(args)
assert_equal(expected_config, built_config)
self.assertEqual(expected_config, built_config)
def test_configure(self):
"""
......@@ -78,7 +77,7 @@ class TestEdit(BaseTest, AutobuildBaselineCompare):
args = ['configure', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethat']
expected_config = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'configure': {'command': 'makethat'}, 'name': 'newbuild'}}}}}, 'version': configfile.AUTOBUILD_CONFIG_VERSION, 'type': 'autobuild'}
built_config = self._try_cmd(args)
assert_equal(expected_config, built_config)
self.assertEqual(expected_config, built_config)
def test_build_configure(self):
"""
......@@ -88,16 +87,16 @@ class TestEdit(BaseTest, AutobuildBaselineCompare):
args = ['configure', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethat']
built_config1 = self._try_cmd(args)
expected_config1 = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'configure': {'command': 'makethat'}, 'name': 'newbuild'}}}}}, 'version': configfile.AUTOBUILD_CONFIG_VERSION, 'type': 'autobuild'}
assert_equal(expected_config1, built_config1)
self.assertEqual(expected_config1, built_config1)
args = ['build', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethis']
built_config2 = self._try_cmd(args)
expected_config2 = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'build': {'command': 'makethis'}, 'name': 'newbuild', 'configure': {'command': 'makethat'}}}}}}, 'version': configfile.AUTOBUILD_CONFIG_VERSION, 'type': 'autobuild'}
assert_equal(expected_config2, built_config2)
self.assertEqual(expected_config2, built_config2)
def test_platform_configure(self):
args = ['platform', "--config-file=%s" % self.tmp_file, 'name=windows', 'build_directory=foo/bar/baz']
built_config = self._try_cmd(args)
assert_equal(built_config['package_description']['platforms']['windows']['build_directory'], 'foo/bar/baz')
self.assertEqual(built_config['package_description']['platforms']['windows']['build_directory'], 'foo/bar/baz')
def tearDown(self):
self.cleanup_tmp_file()
......
......@@ -22,7 +22,6 @@
import sys
import unittest
from nose.plugins.skip import SkipTest
from autobuild.executable import Executable
from .basetest import BaseTest
......@@ -45,7 +44,7 @@ class TestExecutable(BaseTest):
assert otherChildExecutable.get_arguments() == ['foo','.']
# On Windows, you can't count on grep or egrep.
if sys.platform.startswith("win"):
raise SkipTest("On Windows, can't count on finding grep")
raise unittest.SkipTest("On Windows, can't count on finding grep")
result = childExecutable()
assert result == 0, "%s => %s" % (childExecutable._get_all_arguments([]), result)
result = parentExecutable()
......
......@@ -31,6 +31,7 @@ $/LicenseInfo$
import os
import logging
import tempfile
import unittest
try:
# in case graphviz not installed
......@@ -39,10 +40,6 @@ except ImportError:
# in case pydot not installed!
InvocationException = None
from unittest import TestCase
from nose.tools import * # assert_equals() et al.
from nose.plugins.skip import SkipTest
#from autobuild.autobuild_main import Autobuild
import autobuild.common as common
import autobuild.autobuild_tool_graph as graph
......@@ -93,13 +90,13 @@ class TestGraph(BaseTest):
output_lines = stream.getvalue().splitlines()
assert_found_in("label=\"bongo dependencies for ", output_lines) # omit platform
assert_found_in("bingo \\[", output_lines)
assert_in("bingo -> bongo;", output_lines)
self.assertIn("bingo -> bongo;", output_lines)
def test_output(self):
if InvocationException is None:
# If we don't even have pydot installed, this test is pretty
# pointless.
raise SkipTest("pydot not installed, skipping")
raise unittest.SkipTest("pydot not installed, skipping")
self.tmp_dir = tempfile.mkdtemp()
try:
self.options.graph_file = os.path.join(self.tmp_dir, "graph.png")
......@@ -109,7 +106,7 @@ class TestGraph(BaseTest):
graph.AutobuildTool().run(self.options)
except InvocationException as err:
# don't require that graphviz be installed to pass unit tests
raise SkipTest(str(err))
raise unittest.SkipTest(str(err))
# for now, settle for detecting that the png file was created
assert os.path.exists(self.options.graph_file)
assert os.path.exists(self.options.dot_file)
......
......@@ -39,7 +39,6 @@ import urllib.parse
import posixpath
import subprocess
from .basetest import *
from nose.tools import * # assert_equals etc.
from string import Template
from threading import Thread
from http.server import HTTPServer
......@@ -313,7 +312,7 @@ class BaseTest(object):
# set_package() all the time is to avoid confusion with the predefined
# install_config file found in tests/data. If this assertion fires, we
# should pick a different package name for the test.
assert_not_in(package.name, self.config.installables)
self.assertNotIn(package.name, self.config.installables)
self.set_package(package)
def set_package(self, package):
......@@ -350,7 +349,7 @@ class TestInstallArchive(BaseTest):
with CaptureStdout() as stream:
self.options.list_dirty=True
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), 'Dirty Packages: \n')
self.assertEqual(stream.getvalue(), 'Dirty Packages: \n')
def test_dry_run(self):
dry_opts = self.options.copy()
......@@ -452,7 +451,7 @@ class TestInstallArchive(BaseTest):
with CaptureStdout() as stream:
self.options.list_dirty=True
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), 'Dirty Packages: nometa\n')
self.assertEqual(stream.getvalue(), 'Dirty Packages: nometa\n')
def test_conflicting_file(self):
# fail because the package contains a file installed by another package
......@@ -513,7 +512,7 @@ class TestInstallArchive(BaseTest):
self.options.list_archives = True
with CaptureStdout() as stream:
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(set_from_stream(stream), set(('argparse', 'bogus')))
self.assertEqual(set_from_stream(stream), set(('argparse', 'bogus')))
def test_list_licenses(self):
self.options.package = None # install all
......@@ -522,7 +521,7 @@ class TestInstallArchive(BaseTest):
self.options.list_licenses = True
with CaptureStdout() as stream:
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(set_from_stream(stream), set(("GPL", "Apache 2.0", "tut")))
self.assertEqual(set_from_stream(stream), set(("GPL", "Apache 2.0", "tut")))
def test_copyrights(self):
self.options.package = None # install all
......@@ -531,7 +530,7 @@ class TestInstallArchive(BaseTest):
self.options.copyrights = True
with CaptureStdout() as stream:
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), "Copyright 2014 Linden Research, Inc.\nbogus: The Owner\n")
self.assertEqual(stream.getvalue(), "Copyright 2014 Linden Research, Inc.\nbogus: The Owner\n")
def test_versions(self):
self.options.platform=None
......@@ -541,7 +540,7 @@ class TestInstallArchive(BaseTest):
self.options.versions = True
with CaptureStdout() as stream:
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), "bogus: 1\n")
self.assertEqual(stream.getvalue(), "bogus: 1\n")
# ------------------------------------- -------------------------------------
class TestInstallCachedArchive(BaseTest):
......@@ -564,7 +563,7 @@ class TestInstallCachedArchive(BaseTest):
with CaptureStdout() as stream:
self.options.list_dirty=True
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), 'Dirty Packages: \n')
self.assertEqual(stream.getvalue(), 'Dirty Packages: \n')
# ------------------------------------- -------------------------------------
class TestInstallLocalArchive(BaseTest):
......@@ -589,7 +588,7 @@ class TestInstallLocalArchive(BaseTest):
with CaptureStdout() as stream:
self.options.list_dirty=True
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(stream.getvalue(), 'Dirty Packages: bogus\n')
self.assertEqual(stream.getvalue(), 'Dirty Packages: bogus\n')
def test_only_local(self):
self.options.local_archives=[os.path.join(mydir, "data", "bogus-0.1-common-111.tar.bz2")]
......@@ -680,7 +679,7 @@ class TestInstall(BaseTest):
with CaptureStdout() as stream:
self.options.list_archives=True
autobuild_tool_install.AutobuildTool().run(self.options)
assert_equal(set_from_stream(stream), set(("argparse", "bogus")))
self.assertEqual(set_from_stream(stream), set(("argparse", "bogus")))
if __name__ == '__main__':
unittest.main()
......@@ -136,8 +136,7 @@ class TestPackaging(BaseTest):
self.tar_has_expected(self.tar_name)
def test_results(self):
from nose.plugins.skip import SkipTest
raise SkipTest("pydot not installed, skipping")
raise unittest.SkipTest("pydot not installed, skipping")
logger.setLevel(logging.DEBUG)
results_output=tempfile.mktemp()
package.package(self.config, self.config.get_build_directory(None, 'common'),
......
......@@ -30,7 +30,6 @@ import tempfile
import unittest
from autobuild import autobuild_tool_source_environment as atse
from .basetest import *
from nose.tools import *
from .patch import patch
from pprint import pformat
......@@ -40,7 +39,7 @@ def assert_dict_has(d, key, value):
except KeyError:
raise AssertionError("key %s not in %s" % (key, pformat(d)))
else:
assert_equal(dval, value)
self.assertEqual(dval, value)
def assert_dict_subset(d, s):
# Windows insists on capitalizing environment variables, so prepare a copy
......@@ -214,17 +213,17 @@ pprint.pprint(dict(os.environ))'""" % self.shell_path(sys.executable)))
return vars
def test_env(self):
assert 'environment_template' in dir(atse)
self.assertIn('environment_template', dir(atse))
def test_remove_switch(self):
assert_equal(self.source_env_and([], """\
self.assertEqual(self.source_env_and([], """\
switches='abc def ghi'
remove_switch def $switches"""), "abc ghi")
def test_replace_switch(self):
# replace_switch makes no guarantees about the order in which the
# switches are returned.
assert_equal(set(self.source_env_and([], """\
self.assertEqual(set(self.source_env_and([], """\
switches='abc def ghi'
replace_switch def xyz $switches""").split()),
set(["abc", "xyz", "ghi"]))
......@@ -233,9 +232,9 @@ replace_switch def xyz $switches""").split()),
# autobuild source_environment with no arg
stdout, stderr = self.autobuild_outputs()
# ensure that autobuild produced a warning
assert_in("no build variables", stderr)
self.assertIn("no build variables", stderr)
# but emitted normal output anyway
assert_in("set_build_variables", stdout)
self.assertIn("set_build_variables", stdout)
def find_data(self, filename):
return os.path.join(os.path.dirname(__file__), "data", filename)
......@@ -245,16 +244,16 @@ replace_switch def xyz $switches""").split()),
stdout, stderr = self.autobuild_outputs(self.find_data("empty"))
# This also verifies that source_environment doesn't produce errors
# when handed an empty script file.
assert_equal(stderr, "")
self.assertEqual(stderr, "")
def test_var_no_warning(self):
os.environ["AUTOBUILD_VARIABLES_FILE"] = self.find_data("empty")
# autobuild source_environment with no arg but AUTOBUILD_VARIABLES_FILE
stdout, stderr = self.autobuild_outputs()
assert_equal(stderr, "")
self.assertEqual(stderr, "")
def test_no_MAKEFLAGS(self):
assert_not_in("MAKEFLAGS", self.autobuild_outputs()[0])
self.assertNotIn("MAKEFLAGS", self.autobuild_outputs()[0])
def test_no_file_error(self):
with exc(atse.SourceEnvError, "can't read.*nonexistent"):
......@@ -321,8 +320,8 @@ replace_switch def xyz $switches""").split()),
finally:
atse.logger.removeHandler(handler)
stderr = stream.getvalue()
assert_in("platform", stderr)
assert_in("strange", stderr)
self.assertIn("platform", stderr)
self.assertIn("strange", stderr)
def test_config_shorthand(self):
with patch(sys, "platform", "darwin"), CaptureStdout() as stdout:
......
......@@ -29,9 +29,8 @@ $/LicenseInfo$
"""
import re
from unittest import TestCase
from nose.tools import * # assert_equal() et al.
from .basetest import exc
import unittest
from .basetest import *
from .patch import patch
from autobuild import update
......@@ -48,9 +47,9 @@ def test_register():
# directly examining _updaters is fragile; update.py maintenance may
# require changing this test; but _register() has no other observable
# side effects
assert_equal(len(update._updaters["1.1"]), 2)
assert len(update._updaters["1.1"]) == 2
class TestUpdater(TestCase):
class TestUpdater(BaseTest):
def setUp(self):
self.save_confver = update.AUTOBUILD_CONFIG_VERSION
self.save_updaters = update._updaters
......@@ -77,27 +76,27 @@ class TestUpdater(TestCase):
# one previous version, need one updater
triples = update._get_applicable_updaters("NAME", "1.3")
assert_equal(len(triples), 1)
assert_equal(triples[0][:2], ("1.3", "1.4"))
self.assertEqual(len(triples), 1)
self.assertEqual(triples[0][:2], ("1.3", "1.4"))
# two versions older, need two updaters
triples = update._get_applicable_updaters("NAME", "1.2")
assert_equal(len(triples), 2)
assert_equal(triples[0][:2], ("1.2", "1.3"))
assert_equal(triples[1][:2], ("1.3", "1.4"))
self.assertEqual(len(triples), 2)
self.assertEqual(triples[0][:2], ("1.2", "1.3"))
self.assertEqual(triples[1][:2], ("1.3", "1.4"))
# three versions older, need three updaters
triples = update._get_applicable_updaters("NAME", "1.1")
assert_equal(len(triples), 3)
assert_equal(triples[0][:2], ("1.1", "1.2"))
assert_equal(triples[1][:2], ("1.2", "1.3"))
assert_equal(triples[2][:2], ("1.3", "1.4"))
self.assertEqual(len(triples), 3)
self.assertEqual(triples[0][:2], ("1.1", "1.2"))
self.assertEqual(triples[1][:2], ("1.2", "1.3"))
self.assertEqual(triples[2][:2], ("1.3", "1.4"))
# verify that the functions we registered are the ones we get back
config = []
for _, _, func in triples:
config = func(config)
assert_equal(config, ["to 1.2", "to 1.3", "to 1.4"])
self.assertEqual(config, ["to 1.2", "to 1.3", "to 1.4"])
# way way old, so sorry
with exc(update.UpdateError):
......@@ -108,9 +107,9 @@ class TestUpdater(TestCase):
# conversion from 1.2 should now always take the shortcut
triples = update._get_applicable_updaters("NAME", "1.1")
assert_equal(len(triples), 2)
assert_equal(triples[0][:2], ("1.1", "1.2"))
assert_equal(triples[1][:2], ("1.2", "1.4"))
self.assertEqual(len(triples), 2)
self.assertEqual(triples[0][:2], ("1.1", "1.2"))
self.assertEqual(triples[1][:2], ("1.2", "1.4"))
# whoops, suddenly we're trying to reach a version for which we have
# no updater
......@@ -157,12 +156,12 @@ class TestUpdater(TestCase):
# current config needs no update
config, orig_ver = update.convert_to_current("NAME", dict(version="1.4"))
assert_equal(orig_ver, None)
assert "track" not in config, "updater called on current config"
self.assertIsNone(orig_ver)
self.assertNotIn("track", config, msg="updater called on current config")
# oldest supported config gets all updaters
config, orig_ver = update.convert_to_current("NAME", dict(version="1.1"))
assert_equal(orig_ver, "1.1")
assert "track" in config, "updater not called on old config"
assert_equal(config["track"], ["to 1.2", "to 1.3", "to 1.4"])
assert_equal(config["version"], "1.4")
self.assertEqual(orig_ver, "1.1")
self.assertIn("track", config, msg="updater not called on old config")
self.assertEqual(config["track"], ["to 1.2", "to 1.3", "to 1.4"])
self.assertEqual(config["version"], "1.4")
......@@ -43,4 +43,4 @@ $/LicenseInfo$
# will wreak havoc upon new users of your package, as they will not be able to
# install your package without manually installing the dependencies first."
AUTOBUILD_VERSION_STRING = "2.0.3"
AUTOBUILD_VERSION_STRING = "2.0.4"
......@@ -75,7 +75,6 @@ setup(
classifiers=[line for line in CLASSIFIERS.split("\n") if line],
install_requires=['llbase', 'pydot'] + \
(['pysha3'] if sys.version_info[:2] < (3, 6) else []),
extras_require={"dev": ["nose"]},
python_requires=">=3.4",
#ext_modules=ext_modules,
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment