14
0
forked from pool/python-moban
Files
python-moban/remove_nose.patch

1659 lines
53 KiB
Diff
Raw Normal View History

---
setup.py | 2
tests/core/test_context.py | 9 +-
tests/core/test_engine.py | 16 ++--
tests/core/test_moban_factory.py | 41 +++++-----
tests/data_loaders/test_json_loader.py | 3
tests/data_loaders/test_merge_dict.py | 3
tests/data_loaders/test_overrides.py | 18 ++--
tests/data_loaders/test_yaml_loader.py | 12 +--
tests/deprecated/test_handle_requires.py | 10 +-
tests/deprecated/test_repo.py | 19 ++--
tests/integration_tests/test_command_line_options.py | 76 ++++++++-----------
tests/jinja2/test_engine.py | 8 --
tests/jinja2/test_extensions.py | 8 --
tests/jinja2/test_github.py | 6 -
tests/jinja2/test_repr.py | 8 --
tests/jinja2/test_text.py | 6 -
tests/mobanfile/test_mobanfile.py | 24 ++----
tests/mobanfile/test_targets.py | 22 ++---
tests/mobanfile/test_templates.py | 18 ++--
tests/requirements.txt | 1
tests/test_buffered_writer.py | 8 --
tests/test_copy_engine.py | 13 +--
tests/test_definitions.py | 14 +--
tests/test_docs.py | 4 -
tests/test_file_system.py | 49 ++++++------
tests/test_hash_store.py | 7 +
tests/test_main.py | 37 ++++-----
tests/test_reporter.py | 34 ++++----
tests/test_store.py | 4 -
tests/utils.py | 10 +-
30 files changed, 231 insertions(+), 259 deletions(-)
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,4 +1,4 @@
-nose
+pytest
codecov
coverage
mock
--- a/tests/test_file_system.py
+++ b/tests/test_file_system.py
@@ -3,9 +3,12 @@ import sys
import stat
from shutil import rmtree
-from mock import patch
-from nose import SkipTest
-from nose.tools import eq_, raises
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
+from unittest import SkipTest
+import pytest
from moban.externals import file_system
from moban.exceptions import FileNotFound, UnsupportedPyFS2Protocol
@@ -48,7 +51,7 @@ TEST_FILE_CONTENT_SPECS = [
def test_read_unicode():
for url, expected in TEST_FILE_CONTENT_SPECS:
content = file_system.read_unicode(url)
- eq_(content, expected)
+ assert content == expected
TEST_FILE_CONTENT_SPECS_BINARY = [
@@ -61,7 +64,7 @@ TEST_FILE_CONTENT_SPECS_BINARY = [
def test_read_binary():
for url, expected in TEST_FILE_CONTENT_SPECS_BINARY:
content = file_system.read_binary(url)
- eq_(content, expected)
+ assert content == expected
TEST_WRITE_BYTES_SPEC = [
@@ -77,7 +80,7 @@ def test_write_bytes():
for url, expected in TEST_WRITE_BYTES_SPEC:
content = file_system.read_bytes(url)
- eq_(content, expected)
+ assert content == expected
for file_name in ["test.binary", "test.zip", "test.tar"]:
os.unlink(file_name)
@@ -96,14 +99,14 @@ TEST_DIR_SPEC = [
def test_is_dir():
for url, expected in TEST_DIR_SPEC:
status = file_system.is_dir(url)
- eq_(status, expected)
+ assert status == expected
def test_is_file():
for url, is_dir in TEST_DIR_SPEC:
status = file_system.is_file(url)
expected = not is_dir
- eq_(status, expected)
+ assert status == expected
TEST_URL_EXITENCE_SPEC = [
@@ -122,15 +125,15 @@ TEST_URL_EXITENCE_SPEC = [
def test_exists():
for url, expected in TEST_URL_EXITENCE_SPEC:
status = file_system.exists(url)
- eq_(status, expected)
+ assert status == expected
-@raises(UnsupportedPyFS2Protocol)
+@pytest.mark.xfail(raises=UnsupportedPyFS2Protocol)
def test_exists_raise_exception():
file_system.exists("git2://protocol/abc")
-@raises(UnsupportedPyFS2Protocol)
+@pytest.mark.xfail(raises=UnsupportedPyFS2Protocol)
def test_is_file_raise_exception():
file_system.is_file("git2://protocol/abc")
@@ -154,7 +157,7 @@ TEST_LIST_DIR_SPEC = [
def test_list_dir():
for url, expected in TEST_LIST_DIR_SPEC:
file_list = sorted(list(file_system.list_dir(url)))
- eq_(file_list, sorted(expected))
+ assert file_list == sorted(expected)
TEST_FILE_PATH = [
@@ -170,7 +173,7 @@ TEST_FILE_PATH = [
def test_abspath():
for path, expected in TEST_FILE_PATH:
url = file_system.abspath(path)
- eq_(url, expected)
+ assert url == expected
TEST_FILE_URL = [
@@ -187,7 +190,7 @@ TEST_FILE_URL = [
def test_fs_url():
for path, expected in TEST_FILE_URL:
url = file_system.fs_url(path)
- eq_(url, expected.replace("\\", "/"))
+ assert url == expected.replace("\\", "/")
URL_JOIN_TEST_FIXTURES = [
@@ -200,7 +203,7 @@ URL_JOIN_TEST_FIXTURES = [
def test_url_join():
for parent, child, expected_path in URL_JOIN_TEST_FIXTURES:
actual = file_system.url_join(parent, child)
- eq_(actual, expected_path)
+ assert actual == expected_path
def create_file(test_file, permission):
@@ -218,10 +221,8 @@ def test_file_permission_copy():
create_file(test_source, 0o755)
create_file(test_dest, 0o646)
file_system.file_permissions_copy(test_source, test_dest)
- eq_(
- stat.S_IMODE(os.lstat(test_source).st_mode),
- stat.S_IMODE(os.lstat(test_dest).st_mode),
- )
+ assert stat.S_IMODE(os.lstat(test_source).st_mode) == \
+ stat.S_IMODE(os.lstat(test_dest).st_mode)
os.unlink(test_source)
os.unlink(test_dest)
@@ -229,12 +230,12 @@ def test_file_permission_copy():
def file_permissions_disabled_on_windows():
if sys.platform == "win32":
permissions = file_system.file_permissions("abc")
- eq_("no-permission-support", permissions)
+ assert "no-permission-support" == permissions
else:
raise SkipTest("No test required")
-@raises(FileNotFound)
+@pytest.mark.xfail(raises=FileNotFound)
def test_file_permissions_file_not_found():
file_system.file_permissions("I does not exist")
@@ -249,10 +250,8 @@ def test_file_permission_copy_symlink():
os.symlink(test_source, test_symlink)
create_file(test_dest, 0o646)
file_system.file_permissions_copy(test_source, test_dest)
- eq_(
- stat.S_IMODE(os.lstat(test_source).st_mode),
- stat.S_IMODE(os.lstat(test_dest).st_mode),
- )
+ assert stat.S_IMODE(os.lstat(test_source).st_mode) == \
+ stat.S_IMODE(os.lstat(test_dest).st_mode)
os.unlink(test_source)
os.unlink(test_dest)
os.unlink(test_symlink)
--- a/tests/core/test_context.py
+++ b/tests/core/test_context.py
@@ -1,7 +1,6 @@
import os
import fs.path
-from nose.tools import eq_
from moban.core.context import Context
@@ -9,7 +8,7 @@ from moban.core.context import Context
def test_context():
context = Context(fs.path.join("tests", "fixtures"))
data = context.get_data("simple.yaml")
- eq_(data["simple"], "yaml")
+ assert data["simple"] == "yaml"
def test_environ_variables():
@@ -18,7 +17,7 @@ def test_environ_variables():
os.environ[test_var] = test_value
context = Context(fs.path.join("tests", "fixtures"))
data = context.get_data("simple.yaml")
- eq_(data[test_var], test_value)
+ assert data[test_var] == test_value
def test_json_data_overrides_environ_variables():
@@ -27,7 +26,7 @@ def test_json_data_overrides_environ_var
os.environ[test_var] = test_value
context = Context(fs.path.join("tests", "fixtures"))
data = context.get_data("simple.json")
- eq_(data[test_var], test_value)
+ assert data[test_var] == test_value
def test_unknown_data_file():
@@ -36,4 +35,4 @@ def test_unknown_data_file():
os.environ[test_var] = test_value
context = Context(fs.path.join("tests", "fixtures"))
data = context.get_data("unknown.data")
- eq_(data[test_var], test_value)
+ assert data[test_var] == test_value
--- a/tests/core/test_engine.py
+++ b/tests/core/test_engine.py
@@ -1,13 +1,15 @@
import os
import fs.path
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from moban.core import ENGINES
-from moban.definitions import TemplateTarget
-from moban.jinja2.engine import Engine
-from moban.data_loaders.yaml import open_yaml
+from moban.core.definitions import TemplateTarget
+from moban.plugins.jinja2.engine import Engine
+from moban.plugins.yaml_loader import open_yaml
MODULE = "moban.core.moban_factory"
@@ -93,7 +95,7 @@ def test_get_user_defined_engine():
template_types = open_yaml(test_fixture)
ENGINES.register_options(template_types["template_types"])
engine = ENGINES.get_engine("custom_jinja", ".", ".")
- eq_(engine.engine.__class__, Engine)
+ assert engine.engine.__class__ == Engine
def test_custom_file_extension_is_assocated_with_user_defined_engine():
@@ -103,7 +105,7 @@ def test_custom_file_extension_is_assoca
template_types = open_yaml(test_fixture)
ENGINES.register_options(template_types["template_types"])
template_type = ENGINES.get_primary_key("demo_file_suffix")
- eq_("custom_jinja", template_type)
+ assert "custom_jinja" == template_type
def test_built_in_jinja2_file_extension_still_works():
@@ -113,4 +115,4 @@ def test_built_in_jinja2_file_extension_
template_types = open_yaml(test_fixture)
ENGINES.register_options(template_types["template_types"])
template_type = ENGINES.get_primary_key("jj2")
- eq_("jinja2", template_type)
+ assert "jinja2" == template_type
--- a/tests/core/test_moban_factory.py
+++ b/tests/core/test_moban_factory.py
@@ -2,14 +2,17 @@ import os
import sys
import fs.path
-from mock import patch
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from lml.plugin import PluginInfo
-from nose.tools import eq_, raises
+import pytest
import moban.exceptions as exceptions
from moban.core import ENGINES
from moban.core.context import Context
-from moban.jinja2.engine import (
+from moban.plugins.jinja2.engine import (
Engine,
is_extension_list_valid,
import_module_of_extension,
@@ -20,7 +23,7 @@ USER_HOME = fs.path.join("user", "home",
@PluginInfo("library", tags=["testmobans"])
-class TestPypkg:
+class MyTestPypkg:
def __init__(self):
__package_path__ = os.path.normcase(os.path.dirname(__file__))
self.resources_path = os.path.join(__package_path__, "fixtures")
@@ -38,7 +41,7 @@ def test_expand_repo_dir(_, __):
dirs = list(expand_template_directories("git_repo:template"))
expected = [fs.path.join(USER_HOME, "git_repo", "template")]
- eq_(expected, dirs)
+ assert expected == dirs
def test_default_template_type():
@@ -57,22 +60,22 @@ def test_default_mako_type(_): # fake m
assert engine.engine.__class__ == FakeEngine
-@raises(exceptions.NoThirdPartyEngine)
+@pytest.mark.xfail(raises=exceptions.NoThirdPartyEngine)
def test_unknown_template_type():
ENGINES.get_engine("unknown_template_type", [], "")
-@raises(exceptions.DirectoryNotFound)
+@pytest.mark.xfail(raises=exceptions.DirectoryNotFound)
def test_non_existent_tmpl_directries():
ENGINES.get_engine("jj2", "idontexist", "")
-@raises(exceptions.DirectoryNotFound)
+@pytest.mark.xfail(raises=exceptions.DirectoryNotFound)
def test_non_existent_config_directries():
MobanEngine("tests", "abc", Engine)
-@raises(exceptions.DirectoryNotFound)
+@pytest.mark.xfail(raises=exceptions.DirectoryNotFound)
def test_non_existent_ctx_directries():
Context(["abc"])
@@ -84,9 +87,9 @@ def test_file_tests():
engine.render_to_file("file_tests.template", "file_tests.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "yes\nhere")
- eq_(engine.file_count, 1)
- eq_(engine.templated_count, 1)
+ assert content == "yes\nhere"
+ assert engine.file_count == 1
+ assert engine.templated_count == 1
os.unlink(output)
@@ -97,9 +100,9 @@ def test_render_string_to_file():
engine.render_string_to_file("{{test}}", "file_tests.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "here")
- eq_(engine.file_count, 1)
- eq_(engine.templated_count, 1)
+ assert content == "here"
+ assert engine.file_count == 1
+ assert engine.templated_count == 1
os.unlink(output)
@@ -110,7 +113,7 @@ def test_global_template_variables():
engine.render_to_file("variables.template", "variables.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "template: variables.template\ntarget: test.txt\nhere")
+ assert content == "template: variables.template\ntarget: test.txt\nhere"
os.unlink(output)
@@ -121,7 +124,7 @@ def test_nested_global_template_variable
engine.render_to_file("nested.template", "variables.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "template: nested.template\ntarget: test.txt\nhere")
+ assert content == "template: nested.template\ntarget: test.txt\nhere"
os.unlink(output)
@@ -135,7 +138,7 @@ def test_environ_variables_as_data():
engine.render_to_file("test.template", "this_does_not_exist.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "foo")
+ assert content == "foo"
os.unlink(output)
@@ -146,7 +149,7 @@ def test_string_template():
engine.render_string_to_file("{{simple}}", "simple.yaml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "yaml")
+ assert content == "yaml"
os.unlink(output)
@@ -157,7 +160,7 @@ def test_extensions_validator():
for fixture in test_fixtures:
actual.append(is_extension_list_valid(fixture))
- eq_(expected, actual)
+ assert expected == actual
def test_import():
--- a/tests/data_loaders/test_json_loader.py
+++ b/tests/data_loaders/test_json_loader.py
@@ -1,5 +1,4 @@
import fs.path
-from nose.tools import eq_
from moban.plugins.json_loader import open_json
@@ -7,4 +6,4 @@ from moban.plugins.json_loader import op
def test_open_json():
content = open_json(fs.path.join("tests", "fixtures", "child.json"))
expected = {"key": "hello world", "pass": "ox"}
- eq_(expected, content)
+ assert expected == content
--- a/tests/data_loaders/test_merge_dict.py
+++ b/tests/data_loaders/test_merge_dict.py
@@ -1,4 +1,3 @@
-from nose.tools import eq_
from ruamel.yaml import YAML
from moban.core.data_loader import merge
@@ -63,4 +62,4 @@ L1:
"""
)
merged = merge(user, default)
- eq_(merged, {"L1": ["a", "b", "c", "d"]})
+ assert merged == {"L1": ["a", "b", "c", "d"]}
--- a/tests/data_loaders/test_overrides.py
+++ b/tests/data_loaders/test_overrides.py
@@ -1,7 +1,5 @@
import os
-from nose.tools import eq_
-
from moban.main import load_engine_factory_and_engines
from moban.core.data_loader import load_data
@@ -16,9 +14,9 @@ def test_overrides_a_list_of_config_file
("key_from_b", "bee"),
]
for item, expected_item in zip(actual.items(), expected):
- eq_(item, expected_item)
+ assert item == expected_item
- eq_(len(actual), len(expected))
+ assert len(actual) == len(expected)
def test_overrides_a_list_of_config_files_but_cannot_find_them():
@@ -27,9 +25,9 @@ def test_overrides_a_list_of_config_file
expected = [("key", "value")]
for item, expected_item in zip(actual.items(), expected):
- eq_(item, expected_item)
+ assert item == expected_item
- eq_(len(actual), len(expected))
+ assert len(actual) == len(expected)
def test_overrides_ignores_override_sequence():
@@ -42,7 +40,7 @@ def test_overrides_ignores_override_sequ
("key_from_b", "bee"),
]
for item, expected_item in zip(actual.items(), expected):
- eq_(item, expected_item)
+ assert item == expected_item
def test_overrides_select_keys_from_parent_files():
@@ -57,7 +55,7 @@ def test_overrides_select_keys_from_pare
("beta", "from b"),
]
for item, expected_item in zip(actual.items(), expected):
- eq_(item, expected_item)
+ assert item == expected_item
def test_overrides_select_keys():
@@ -72,7 +70,7 @@ def test_overrides_select_keys():
("beta", "from b"),
]
for item, expected_item in zip(actual.items(), expected):
- eq_(item, expected_item)
+ assert item == expected_item
def test_overrides_nested_keys():
@@ -92,7 +90,7 @@ def test_overrides_nested_keys():
"tessel": {"version": 2, "USB": "micro", "wifi": "802.11gn"},
}
- eq_(dict(actual), expected)
+ assert dict(actual) == expected
def test_overrides_fs_url():
--- a/tests/data_loaders/test_yaml_loader.py
+++ b/tests/data_loaders/test_yaml_loader.py
@@ -1,5 +1,5 @@
import fs.path
-from nose.tools import eq_, raises
+import pytest
from moban.core.data_loader import load_data
from moban.plugins.yaml_loader import open_yaml
@@ -8,28 +8,28 @@ from moban.plugins.yaml_loader import op
def test_simple_yaml():
test_file = fs.path.join("tests", "fixtures", "simple.yaml")
data = open_yaml(test_file)
- eq_(data, {"simple": "yaml"})
+ assert data == {"simple": "yaml"}
def test_inheritance_yaml():
test_file = fs.path.join("tests", "fixtures", "child.yaml")
data = load_data(fs.path.join("tests", "fixtures", "config"), test_file)
- eq_(data, {"key": "hello world", "pass": "ox"})
+ assert data == {"key": "hello world", "pass": "ox"}
def test_exception():
test_file = fs.path.join("tests", "fixtures", "orphan.yaml")
data = load_data(fs.path.join("tests", "fixtures", "config"), test_file)
- eq_(len(data), 0)
+ assert len(data) == 0
-@raises(IOError)
+@pytest.mark.xfail(raises=IOError)
def test_exception_2():
test_file = fs.path.join("tests", "fixtures", "dragon.yaml")
load_data(fs.path.join("tests", "fixtures", "config"), test_file)
-@raises(IOError)
+@pytest.mark.xfail(raises=IOError)
def test_exception_3():
test_file = fs.path.join("tests", "fixtures", "dragon.yaml")
load_data(None, test_file)
--- a/tests/deprecated/test_handle_requires.py
+++ b/tests/deprecated/test_handle_requires.py
@@ -1,5 +1,7 @@
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from moban.deprecated import GitRequire
@@ -60,7 +62,7 @@ def test_handle_requires_repos_with_subm
fake_git_clone.assert_called_with(
[GitRequire(git_url="https://github.com/my/repo", submodule=True)]
)
- eq_(fake_pip_install.called, False)
+ assert fake_pip_install.called == False
def test_is_repo():
@@ -75,4 +77,4 @@ def test_is_repo():
actual = [is_repo(repo) for repo in repos]
expected = [True, True, True, False, False]
- eq_(expected, actual)
+ assert expected == actual
--- a/tests/deprecated/test_repo.py
+++ b/tests/deprecated/test_repo.py
@@ -1,6 +1,9 @@
import fs.path
-from mock import patch
-from nose.tools import eq_, raises
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
+import pytest
from moban.deprecated import GitRequire
from moban.exceptions import NoGitCommand
@@ -44,7 +47,7 @@ class TestGitFunctions:
depth=2,
)
repo = fake_repo.return_value
- eq_(repo.git.submodule.called, False)
+ assert repo.git.submodule.called == False
def test_checkout_new_with_submodules(
self, fake_repo, local_folder_exists, *_
@@ -89,7 +92,7 @@ class TestGitFunctions:
depth=2,
)
repo = fake_repo.return_value
- eq_(repo.git.submodule.called, False)
+ assert repo.git.submodule.called == False
def test_update_existing_with_branch_parameter(
self, fake_repo, local_folder_exists, *_
@@ -112,7 +115,7 @@ class TestGitFunctions:
depth=2,
)
repo = fake_repo.return_value
- eq_(repo.git.submodule.called, False)
+ assert repo.git.submodule.called == False
def test_update_existing_with_reference_parameter(
self, fake_repo, local_folder_exists, *_
@@ -135,7 +138,7 @@ def test_get_repo_name():
]
actual = [get_repo_name(repo) for repo in repos]
expected = ["repo"] * len(repos)
- eq_(expected, actual)
+ assert expected == actual
@patch("moban.reporter.report_error_message")
@@ -152,10 +155,10 @@ def test_get_repo_name_can_handle_invali
@patch("appdirs.user_cache_dir", return_value="root")
def test_get_moban_home(_):
actual = get_moban_home()
- eq_(fs.path.join("root", "repos"), actual)
+ assert fs.path.join("root", "repos") == actual
-@raises(NoGitCommand)
+@pytest.mark.xfail(raises=NoGitCommand)
@patch("subprocess.check_output", side_effect=Exception)
def test_make_git_is_available(_):
make_sure_git_is_available()
--- a/tests/integration_tests/test_command_line_options.py
+++ b/tests/integration_tests/test_command_line_options.py
@@ -2,9 +2,12 @@ import os
import sys
from shutil import copyfile
-from mock import MagicMock, patch
-from nose import SkipTest
-from nose.tools import eq_, raises, assert_raises
+try:
+ from mock import MagicMock, patch
+except ImportError:
+ from unittest.mock import MagicMock, patch
+from unittest import SkipTest
+import pytest
from moban.core.definitions import TemplateTarget
@@ -57,7 +60,7 @@ class TestCustomOptions:
"a.jj2", "config.yaml", "moban.output"
)
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
def test_missing_template(self):
test_args = ["moban", "-c", self.config_file]
fake_stdin = MagicMock(isatty=MagicMock(return_value=True))
@@ -105,7 +108,7 @@ class TestOptions:
string_template, "data.yml", "moban.output"
)
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
def test_no_argments(self):
test_args = ["moban"]
fake_stdin = MagicMock(isatty=MagicMock(return_value=True))
@@ -143,17 +146,15 @@ class TestNoOptions:
main()
call_args = list(fake_template_doer.call_args[0][0])
- eq_(
- call_args,
+ assert call_args == \
[
TemplateTarget(
"README.rst.jj2", "data.yaml", "README.rst"
),
TemplateTarget("setup.py.jj2", "data.yaml", "setup.py"),
- ],
- )
+ ]
- @raises(Exception)
+ @pytest.mark.xfail(raises=Exception)
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
def test_single_command_with_missing_output(self, fake_template_doer):
test_args = ["moban", "-t", "README.rst.jj2"]
@@ -171,10 +172,8 @@ class TestNoOptions:
main()
call_args = list(fake_template_doer.call_args[0][0])
- eq_(
- call_args,
- [TemplateTarget("README.rst.jj2", "data.yaml", "xyz.output")],
- )
+ assert call_args == \
+ [TemplateTarget("README.rst.jj2", "data.yaml", "xyz.output")]
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
def test_single_command_with_options(self, fake_template_doer):
@@ -192,12 +191,10 @@ class TestNoOptions:
main()
call_args = list(fake_template_doer.call_args[0][0])
- eq_(
- call_args,
- [TemplateTarget("README.rst.jj2", "new.yml", "xyz.output")],
- )
+ assert call_args == \
+ [TemplateTarget("README.rst.jj2", "new.yml", "xyz.output")]
- @raises(Exception)
+ @pytest.mark.xfail(raises=Exception)
def test_single_command_without_output_option(self):
test_args = ["moban", "-t", "abc.jj2"]
with patch.object(sys, "argv", test_args):
@@ -234,15 +231,13 @@ class TestNoOptions2:
main()
call_args = list(fake_template_doer.call_args[0][0])
- eq_(
- call_args,
+ assert call_args == \
[
TemplateTarget(
"README.rst.jj2", "data.yaml", "README.rst"
),
TemplateTarget("setup.py.jj2", "data.yaml", "setup.py"),
- ],
- )
+ ]
def tearDown(self):
self.patcher1.stop()
@@ -272,15 +267,13 @@ class TestCustomMobanFile:
main()
call_args = list(fake_template_doer.call_args[0][0])
- eq_(
- call_args,
+ assert call_args == \
[
TemplateTarget(
"README.rst.jj2", "data.yaml", "README.rst"
),
TemplateTarget("setup.py.jj2", "data.yaml", "setup.py"),
- ],
- )
+ ]
def tearDown(self):
self.patcher1.stop()
@@ -334,7 +327,8 @@ def test_duplicated_targets_in_moban_fil
with patch.object(sys, "argv", test_args):
from moban.main import main
- assert_raises(SystemExit, main)
+ with pytest.raises(SystemExit):
+ main()
os.unlink(".moban.yml")
@@ -342,7 +336,7 @@ class TestInvalidMobanFile:
def setUp(self):
self.config_file = ".moban.yml"
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
def test_no_configuration(self, fake_template_doer):
with open(self.config_file, "w") as f:
@@ -353,7 +347,7 @@ class TestInvalidMobanFile:
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
def test_no_configuration_2(self, fake_template_doer):
with open(self.config_file, "w") as f:
@@ -364,7 +358,7 @@ class TestInvalidMobanFile:
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
def test_no_targets(self, fake_template_doer):
with open(self.config_file, "w") as f:
@@ -403,15 +397,13 @@ class TestComplexOptions:
) as fake:
main()
call_args = list(fake.call_args[0][0])
- eq_(
- call_args,
+ assert call_args == \
[
TemplateTarget(
"README.rst.jj2", "custom-data.yaml", "README.rst"
),
TemplateTarget("setup.py.jj2", "data.yml", "setup.py"),
- ],
- )
+ ]
def tearDown(self):
os.unlink(self.config_file)
@@ -439,7 +431,7 @@ class TestTemplateTypeOption:
os.unlink(self.config_file)
-@raises(SystemExit)
+@pytest.mark.xfail(raises=SystemExit)
def test_version_option():
test_args = ["moban", "-V"]
with patch.object(sys, "argv", test_args):
@@ -497,7 +489,7 @@ def test_git_repo_example(_):
main()
with open("test_git_repo_example.py") as f:
content = f.read()
- eq_(content, '__version__ = "0.1.1rc3"\n__author__ = "C.W."\n')
+ assert content == '__version__ = "0.1.1rc3"\n__author__ = "C.W."\n'
os.unlink("test_git_repo_example.py")
@@ -518,7 +510,7 @@ def test_pypi_pkg_example(_):
main()
with open("test_pypi_pkg_example.py") as f:
content = f.read()
- eq_(content, '__version__ = "0.1.1rc3"\n__author__ = "C.W."\n')
+ assert content == '__version__ = "0.1.1rc3"\n__author__ = "C.W."\n'
os.unlink("test_pypi_pkg_example.py")
@@ -548,10 +540,8 @@ def test_add_extension():
main()
with open("moban.output") as f:
content = f.read()
- eq_(
- content,
- "{}.{}".format(sys.version_info[0], sys.version_info[1]),
- )
+ assert content == \
+ "{}.{}".format(sys.version_info[0], sys.version_info[1])
os.unlink("moban.output")
@@ -566,5 +556,5 @@ def test_stdin_input():
main()
with open("moban.output") as f:
content = f.read()
- eq_(content, "world")
+ assert content == "world"
os.unlink("moban.output")
--- a/tests/jinja2/test_engine.py
+++ b/tests/jinja2/test_engine.py
@@ -1,9 +1,7 @@
import os
-from nose.tools import eq_
-
-from moban import file_system
-from moban.jinja2.engine import Engine
+from moban.externals import file_system
+from moban.plugins.jinja2.engine import Engine
def test_jinja2_template():
@@ -14,7 +12,7 @@ def test_jinja2_template():
data = dict(test="here")
result = engine.apply_template(template, data, None)
expected = "yes\nhere"
- eq_(expected, result)
+ assert expected == result
def test_jinja2_template_string():
@@ -25,4 +23,4 @@ def test_jinja2_template_string():
data = dict(test="here")
result = engine.apply_template(template, data, None)
expected = "here"
- eq_(expected, result)
+ assert expected == result
--- a/tests/jinja2/test_extensions.py
+++ b/tests/jinja2/test_extensions.py
@@ -1,10 +1,8 @@
import os
-from nose.tools import eq_
-
-from moban import file_system
-from moban.jinja2.engine import Engine
-from moban.jinja2.extensions import jinja_global
+from moban.externals import file_system
+from moban.plugins.jinja2.engine import Engine
+from moban.plugins.jinja2.extensions import jinja_global
from moban.core.moban_factory import MobanEngine
@@ -18,5 +16,5 @@ def test_globals():
engine.render_to_file("basic.template", "basic.yml", output)
with open(output, "r") as output_file:
content = output_file.read()
- eq_(content, "world\n\ntest")
+ assert content == "world\n\ntest"
os.unlink(output)
--- a/tests/jinja2/test_github.py
+++ b/tests/jinja2/test_github.py
@@ -1,6 +1,4 @@
-from nose.tools import eq_
-
-from moban.jinja2.filters.github import github_expand
+from moban.plugins.jinja2.filters.github import github_expand
def test_github_expand():
@@ -36,4 +34,4 @@ def test_github_expand():
]
for input_line, expect in zip(inputs, expectations):
actual = github_expand(*input_line)
- eq_(actual, expect)
+ assert actual == expect
--- a/tests/jinja2/test_repr.py
+++ b/tests/jinja2/test_repr.py
@@ -1,15 +1,13 @@
-from nose.tools import eq_
-
-from moban.jinja2.filters.repr import repr as repr_function
+from moban.plugins.jinja2.filters.repr import repr as repr_function
def test_string():
me = "abc"
expected = repr_function(me)
- eq_(expected, "'abc'")
+ assert expected == "'abc'"
def test_list():
me = [1, 2, 3]
expected = repr_function(me)
- eq_(expected, ["'1'", "'2'", "'3'"])
+ assert expected == ["'1'", "'2'", "'3'"]
--- a/tests/jinja2/test_text.py
+++ b/tests/jinja2/test_text.py
@@ -1,6 +1,4 @@
-from nose.tools import eq_
-
-from moban.jinja2.filters.text import split_length
+from moban.plugins.jinja2.filters.text import split_length
def test_split_length():
@@ -18,4 +16,4 @@ def test_split_length():
]
for test, expect in zip(inputs, expectations):
actual = split_length(*test)
- eq_(list(actual), expect)
+ assert list(actual) == expect
--- a/tests/mobanfile/test_targets.py
+++ b/tests/mobanfile/test_targets.py
@@ -1,7 +1,7 @@
import uuid
import fs.path
-from nose.tools import eq_, raises
+import pytest
from moban.exceptions import GroupTargetNotFound
from moban.core.mobanfile import targets
@@ -31,7 +31,7 @@ def test_handling_group_target():
expected = [
TemplateTarget(TEMPLATE, CONFIGURATION, OUTPUT, group_template_type)
]
- eq_(expected, actual)
+ assert expected == actual
def test_extract_group_targets():
@@ -41,17 +41,17 @@ def test_extract_group_targets():
]
actual = targets.extract_group_targets("copy1", test_targets)
expected = [{"copy1": [{"output1": "source1"}]}]
- eq_(expected, actual)
+ assert expected == actual
-@raises(GroupTargetNotFound)
+@pytest.mark.xfail(raises=GroupTargetNotFound)
def test_extract_group_targets_not_found():
test_targets = [
{"copy": [{"output": "source"}], "copy1": [{"output1": "source1"}]}
]
actual = targets.extract_group_targets("copy2", test_targets)
expected = []
- eq_(expected, actual)
+ assert expected == actual
class TestImplicitTarget:
@@ -67,7 +67,7 @@ class TestImplicitTarget:
targets._handle_implicit_target(options, TEMPLATE, OUTPUT)
)
expected = [TemplateTarget(TEMPLATE, CONFIGURATION, OUTPUT, "jj2")]
- eq_(expected, actual)
+ assert expected == actual
def test_use_moban_default_template_from_options(self):
template_without_suffix = "template"
@@ -91,7 +91,7 @@ class TestImplicitTarget:
DEFAULT_TEMPLATE_TYPE,
)
]
- eq_(expected, actual)
+ assert expected == actual
class TestExplicitTarget:
@@ -106,7 +106,7 @@ class TestExplicitTarget:
actual = list(targets._handle_explicit_target(options, target))
expected = [TemplateTarget(TEMPLATE, CONFIGURATION, OUTPUT, "use-me")]
- eq_(expected, actual)
+ assert expected == actual
def test_derive_template_type_from_target_template_file(self):
@@ -119,7 +119,7 @@ class TestExplicitTarget:
actual = list(targets._handle_explicit_target(options, target))
expected = [TemplateTarget(TEMPLATE, CONFIGURATION, OUTPUT, "jj2")]
- eq_(expected, actual)
+ assert expected == actual
def test_use_moban_default_template_from_options(self):
template_without_suffix = "template"
@@ -139,7 +139,7 @@ class TestExplicitTarget:
DEFAULT_TEMPLATE_TYPE,
)
]
- eq_(expected, actual)
+ assert expected == actual
def test_ad_hoc_type(self):
target = dict(template=TEMPLATE, output=OUTPUT)
@@ -163,4 +163,4 @@ class TestExplicitTarget:
expected = [
TemplateTarget(TEMPLATE, CONFIGURATION, OUTPUT, file_extension)
]
- eq_(actual, expected)
+ assert actual == expected
--- a/tests/mobanfile/test_templates.py
+++ b/tests/mobanfile/test_templates.py
@@ -1,6 +1,8 @@
import fs.path
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from moban.core.mobanfile.templates import handle_template
@@ -14,7 +16,7 @@ class TestHandleTemplateFunction:
handle_template("copier-test01.csv", "/tmp/test", self.base_dir)
)
expected = [("copier-test01.csv", "/tmp/test", "csv")]
- eq_(expected, results)
+ assert expected == results
@patch("moban.externals.reporter.report_error_message")
def test_file_not_found(self, reporter):
@@ -39,7 +41,7 @@ class TestHandleTemplateFunction:
None,
)
]
- eq_(expected, results)
+ assert expected == results
def test_listing_dir_recusively(self):
test_dir = "/tmp/copy-a-directory"
@@ -60,10 +62,8 @@ class TestHandleTemplateFunction:
None,
),
]
- eq_(
- sorted(results, key=lambda x: x[0]),
- sorted(expected, key=lambda x: x[0]),
- )
+ assert sorted(results, key=lambda x: x[0]) == \
+ sorted(expected, key=lambda x: x[0])
@patch("moban.externals.reporter.report_error_message")
def test_listing_dir_recusively_with_error(self, reporter):
@@ -73,4 +73,4 @@ class TestHandleTemplateFunction:
"copier-directory-does-not-exist/**", test_dir, self.base_dir
)
)
- eq_(reporter.call_count, 1)
+ assert reporter.call_count == 1
--- a/tests/test_buffered_writer.py
+++ b/tests/test_buffered_writer.py
@@ -1,8 +1,6 @@
import os
import tempfile
-from nose.tools import eq_
-
from moban.externals import file_system
from moban.externals.buffered_writer import BufferedWriter, write_file_out
@@ -25,7 +23,7 @@ class TestBufferedWriter:
self.writer.write_file_out(test_file, CONTENT)
self.writer.close()
content = file_system.read_text(test_file)
- eq_(content, EXPECTED)
+ assert content == EXPECTED
os.unlink(test_file)
def test_write_a_zip(self):
@@ -34,7 +32,7 @@ class TestBufferedWriter:
self.writer.write_file_out(test_file, CONTENT)
self.writer.close()
content = file_system.read_text(test_file)
- eq_(content, EXPECTED)
+ assert content == EXPECTED
os.unlink(os.path.join(tmp_dir, "testout.zip"))
@@ -43,4 +41,4 @@ def test_write_file_out():
write_file_out(test_file, CONTENT)
with open(test_file, "r") as f:
content = f.read()
- eq_(content, EXPECTED)
+ assert content == EXPECTED
--- a/tests/test_copy_engine.py
+++ b/tests/test_copy_engine.py
@@ -1,7 +1,6 @@
import os
import fs.path
-from nose.tools import eq_
from moban.core import ENGINES
from moban.externals import file_system
@@ -17,23 +16,23 @@ class TestContentForwardEngine:
def test_get_template(self):
template_content = self.engine.get_template("copier-test01.csv")
# remove '\r' for windows
- eq_("test 01\n", template_content.decode("utf-8").replace("\r", ""))
+ assert "test 01\n" == template_content.decode("utf-8").replace("\r", "")
def test_encoding_of_template(self):
template_content_ = self.engine.get_template("coala_color.svg")
with open("tests/fixtures/coala_color.svg", "r") as expected:
expected = expected.read()
- eq_(expected, template_content_.decode("utf-8").replace("\r", ""))
+ assert expected == template_content_.decode("utf-8").replace("\r", "")
def test_get_template_from_string(self):
test_content = "simply forwarded"
template_content = self.engine.get_template_from_string(test_content)
- eq_(test_content, template_content)
+ assert test_content == template_content
def test_apply_template(self):
test_content = "simply forwarded"
template_content = self.engine.apply_template(test_content, "not used")
- eq_(test_content, template_content)
+ assert test_content == template_content
class TestCopyEncoding:
@@ -47,8 +46,8 @@ class TestCopyEncoding:
template_content = self.engine.get_template("coala_color.svg")
with open("tests/fixtures/coala_color.svg", "rb") as expected:
expected = expected.read()
- eq_(expected, template_content)
+ assert expected == template_content
template_content = self.engine.get_template("non-unicode.char")
with open("tests/fixtures/non-unicode.char", "rb") as expected:
expected = expected.read()
- eq_(expected, template_content)
+ assert expected == template_content
--- a/tests/test_definitions.py
+++ b/tests/test_definitions.py
@@ -1,24 +1,22 @@
-from nose.tools import eq_
-
from moban.deprecated import GitRequire
from moban.core.definitions import TemplateTarget
def test_git_require_repr():
require = GitRequire(git_url="http://github.com/some/repo")
- eq_("http://github.com/some/repo,None,False", repr(require))
+ assert "http://github.com/some/repo,None,False" == repr(require)
def test_template_target_repr():
require = TemplateTarget("template_file", "dat_file", "output")
- eq_("template_file,dat_file,output,jinja2", repr(require))
+ assert "template_file,dat_file,output,jinja2" == repr(require)
def test_template_target_output_suffix_change():
require = TemplateTarget(
"template_file", "dat_file", "output.copy", template_type="copy"
)
- eq_("template_file,dat_file,output,copy", repr(require))
+ assert "template_file,dat_file,output,copy" == repr(require)
def test_template_target_output_suffix_updates_after_set():
@@ -26,14 +24,14 @@ def test_template_target_output_suffix_u
"template_file", "dat_file", "output.copy", template_type="copy"
)
require.set_template_type("jinja2")
- eq_("template_file,dat_file,output.copy,jinja2", repr(require))
+ assert "template_file,dat_file,output.copy,jinja2" == repr(require)
def test_clone_params():
require = GitRequire(git_url="http://github.com/some/repo")
actual = require.clone_params()
expected = {"single_branch": True, "depth": 2}
- eq_(expected, actual)
+ assert expected == actual
def test_branch_params():
@@ -42,4 +40,4 @@ def test_branch_params():
)
actual = require.clone_params()
expected = {"single_branch": True, "branch": "ghpages", "depth": 2}
- eq_(expected, actual)
+ assert expected == actual
--- a/tests/test_docs.py
+++ b/tests/test_docs.py
@@ -1,7 +1,5 @@
import os
-from nose.tools import eq_
-
from .utils import Docs, custom_dedent
@@ -314,7 +312,7 @@ class TestTutorial(Docs):
["moban", "-g", "copy"], folder, [("simple.file", expected)]
)
# make sure only copy target is executed
- eq_(False, os.path.exists("a.output"))
+ assert False == os.path.exists("a.output")
def test_level_22_intermediate_targets(self):
expected = "a world\n"
--- a/tests/test_hash_store.py
+++ b/tests/test_hash_store.py
@@ -1,8 +1,11 @@
import os
import sys
-from unittest.mock import patch
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
-from nose import SkipTest
+from unittest import SkipTest
from moban.externals import file_system
from moban.exceptions import NoPermissionsNeeded
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -2,8 +2,11 @@ import os
import sys
from shutil import copyfile
-from mock import MagicMock, patch
-from nose.tools import eq_, raises, assert_raises
+try:
+ from mock import MagicMock, patch
+except ImportError:
+ from unittest.mock import MagicMock, patch
+import pytest
import moban.exceptions as exceptions
@@ -19,7 +22,7 @@ class TestException:
if os.path.exists(self.data_file):
os.unlink(self.data_file)
- @raises(exceptions.MobanfileGrammarException)
+ @pytest.mark.xfail(raises=exceptions.MobanfileGrammarException)
def test_handle_moban_file(self):
copyfile(
os.path.join("tests", "fixtures", ".moban-version-1234.yml"),
@@ -54,17 +57,13 @@ class TestException:
]
for data in (yaml.load(d) for d in invalid_data):
- assert_raises(
- exceptions.MobanfileGrammarException,
- main.check_none,
- data,
- ".moban.yaml",
- )
+ with pytest.raises(exceptions.MobanfileGrammarException):
+ main.check_none(data, ".moban.yaml")
for data in (yaml.load(d) for d in valid_data):
main.check_none(data, ".moban.yaml")
- @raises(exceptions.MobanfileGrammarException)
+ @pytest.mark.xfail(raises=exceptions.MobanfileGrammarException)
def test_version_1_is_recognized(self):
copyfile(
os.path.join("tests", "fixtures", ".moban-version-1.0.yml"),
@@ -78,7 +77,7 @@ class TestException:
main.handle_moban_file(self.moban_file, {})
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("os.path.exists")
@patch("moban.main.handle_moban_file")
@patch("moban.externals.reporter.report_error_message")
@@ -94,7 +93,7 @@ class TestException:
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("os.path.exists")
@patch("moban.main.handle_moban_file")
@patch("moban.externals.reporter.report_error_message")
@@ -108,7 +107,7 @@ class TestException:
with patch.object(sys, "argv", ["moban"]):
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("os.path.exists")
@patch("moban.main.handle_command_line")
@patch("moban.externals.reporter.report_error_message")
@@ -124,7 +123,7 @@ class TestException:
with patch.object(sys, "argv", ["moban"]):
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("os.path.exists")
@patch("moban.main.handle_moban_file")
@patch("moban.externals.reporter.report_error_message")
@@ -140,7 +139,7 @@ class TestException:
with patch.object(sys, "argv", ["moban"]):
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("os.path.exists")
@patch("moban.main.handle_moban_file")
@patch("moban.externals.reporter.report_error_message")
@@ -158,7 +157,7 @@ class TestException:
class TestExitCodes:
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("moban.main.handle_moban_file")
@patch("moban.main.find_default_moban_file")
def test_has_many_files_with_exit_code(
@@ -171,7 +170,7 @@ class TestExitCodes:
with patch.object(sys, "argv", ["moban", "--exit-code"]):
main()
- @raises(SystemExit)
+ @pytest.mark.xfail(raises=SystemExit)
@patch("moban.main.handle_command_line")
@patch("moban.main.find_default_moban_file")
def test_handle_single_change_with_exit_code(
@@ -220,14 +219,14 @@ class TestFinder:
from moban.main import find_default_moban_file
actual = find_default_moban_file()
- eq_(".moban.yml", actual)
+ assert ".moban.yml" == actual
def test_moban_yaml(self):
self.fake_file_existence.side_effect = [False, True]
from moban.main import find_default_moban_file
actual = find_default_moban_file()
- eq_(".moban.yaml", actual)
+ assert ".moban.yaml" == actual
def test_no_moban_file(self):
self.fake_file_existence.side_effect = [False, False]
--- a/tests/test_reporter.py
+++ b/tests/test_reporter.py
@@ -1,7 +1,9 @@
import sys
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from moban.externals import reporter
@@ -17,7 +19,7 @@ def test_partial_run():
fake_stdout = patcher.start()
reporter.report_partial_run("Actioned", 1, 20)
patcher.stop()
- eq_(fake_stdout.getvalue(), "Actioned 1 out of 20 files.\n")
+ assert fake_stdout.getvalue() == "Actioned 1 out of 20 files.\n"
def test_full_run():
@@ -25,7 +27,7 @@ def test_full_run():
fake_stdout = patcher.start()
reporter.report_full_run("Worked on", 20)
patcher.stop()
- eq_(fake_stdout.getvalue(), "Worked on 20 files.\n")
+ assert fake_stdout.getvalue() == "Worked on 20 files.\n"
def test_error_message():
@@ -33,7 +35,7 @@ def test_error_message():
fake_stdout = patcher.start()
reporter.report_error_message("something wrong")
patcher.stop()
- eq_(fake_stdout.getvalue(), "Error: something wrong\n")
+ assert fake_stdout.getvalue() == "Error: something wrong\n"
def test_info_message():
@@ -41,7 +43,7 @@ def test_info_message():
fake_stdout = patcher.start()
reporter.report_info_message("for your information")
patcher.stop()
- eq_(fake_stdout.getvalue(), "Info: for your information\n")
+ assert fake_stdout.getvalue() == "Info: for your information\n"
def test_warning_message():
@@ -49,7 +51,7 @@ def test_warning_message():
fake_stdout = patcher.start()
reporter.report_warning_message("Maybe you wanna know")
patcher.stop()
- eq_(fake_stdout.getvalue(), "Warning: Maybe you wanna know\n")
+ assert fake_stdout.getvalue() == "Warning: Maybe you wanna know\n"
def test_report_templating():
@@ -57,7 +59,7 @@ def test_report_templating():
fake_stdout = patcher.start()
reporter.report_templating("Transforming", "a", "b")
patcher.stop()
- eq_(fake_stdout.getvalue(), "Transforming a to b\n")
+ assert fake_stdout.getvalue() == "Transforming a to b\n"
def test_no_action():
@@ -65,13 +67,13 @@ def test_no_action():
fake_stdout = patcher.start()
reporter.report_no_action()
patcher.stop()
- eq_(fake_stdout.getvalue(), "No actions performed\n")
+ assert fake_stdout.getvalue() == "No actions performed\n"
def test_format_single():
message = "1 files"
ret = reporter._format_single(message, 1)
- eq_(ret, "1 file")
+ assert ret == "1 file"
def test_report_template_not_in_moban_file():
@@ -79,10 +81,8 @@ def test_report_template_not_in_moban_fi
fake_stdout = patcher.start()
reporter.report_template_not_in_moban_file("test.jj2")
patcher.stop()
- eq_(
- fake_stdout.getvalue(),
- "Warning: test.jj2 is not defined in your moban file!\n",
- )
+ assert fake_stdout.getvalue() == \
+ "Warning: test.jj2 is not defined in your moban file!\n"
def test_report_file_extension_not_needed():
@@ -90,7 +90,5 @@ def test_report_file_extension_not_neede
fake_stdout = patcher.start()
reporter.report_file_extension_not_needed()
patcher.stop()
- eq_(
- fake_stdout.getvalue(),
- "Info: File extension is not required for ad-hoc type\n",
- )
+ assert fake_stdout.getvalue() == \
+ "Info: File extension is not required for ad-hoc type\n"
--- a/tests/test_store.py
+++ b/tests/test_store.py
@@ -1,5 +1,3 @@
-from nose.tools import eq_
-
from moban.core.definitions import TemplateTarget
from moban.core.mobanfile.store import Store
@@ -9,4 +7,4 @@ def test_store():
output = "output"
target = TemplateTarget("template_file", "data_file", output)
store.add(target)
- eq_(target, store.look_up_by_output.get(output))
+ assert target == store.look_up_by_output.get(output)
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -2,8 +2,10 @@ import os
import sys
from textwrap import dedent
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from fs.opener.parse import parse_fs_url
from moban.main import main
@@ -13,12 +15,12 @@ from moban.externals import file_system
def verify_content(file_name, expected):
with open(file_name, "r") as f:
content = f.read()
- eq_(content, expected)
+ assert content == expected
def verify_content_with_fs(file_name, expected):
content = file_system.read_unicode(file_name)
- eq_(content, expected)
+ assert content == expected
def run_moban(args, folder, criterias):
--- a/setup.py
+++ b/setup.py
@@ -261,7 +261,7 @@ if __name__ == "__main__":
keywords=KEYWORDS,
python_requires=PYTHON_REQUIRES,
extras_require=EXTRAS_REQUIRE,
- tests_require=["nose"],
+ tests_require=["pytest"],
install_requires=INSTALL_REQUIRES,
packages=PACKAGES,
include_package_data=True,
--- a/tests/mobanfile/test_mobanfile.py
+++ b/tests/mobanfile/test_mobanfile.py
@@ -1,6 +1,8 @@
import fs.path
-from mock import patch
-from nose.tools import eq_
+try:
+ from mock import patch
+except ImportError:
+ from unittest.mock import patch
from moban.core.definitions import TemplateTarget
@@ -25,8 +27,7 @@ def test_handle_targets(fake_renderer):
handle_targets(options, short_hand_targets)
call_args = list(fake_renderer.call_args[0][0])
- eq_(
- call_args,
+ assert call_args == \
[
TemplateTarget(
"copier-test01.csv",
@@ -34,8 +35,7 @@ def test_handle_targets(fake_renderer):
"output.csv",
template_type="jinja2",
)
- ],
- )
+ ]
@patch("moban.core.moban_factory.MobanEngine.render_to_files")
@@ -63,21 +63,17 @@ def test_handle_targets_sequence(fake_re
call_args = list(fake_renderer.call_args_list)
- eq_(
- call_args[0][0][0][0],
+ assert call_args[0][0][0][0] == \
TemplateTarget(
"a.template.jj2",
"child.yaml",
"filterme.handlebars",
template_type="jj2",
- ),
- )
- eq_(
- call_args[1][0][0][0],
+ )
+ assert call_args[1][0][0][0] == \
TemplateTarget(
"filterme.handlebars",
"child.yaml",
"filtered_output.txt",
template_type="handlebars",
- ),
- )
+ )
--- /dev/null
+++ b/tests/core/__init__.py
@@ -0,0 +1 @@
+# This file is intentionally left blank.
\ No newline at end of file
--- /dev/null
+++ b/tests/jinja2/__init__.py
@@ -0,0 +1 @@
+# This file is intentionally left blank.
\ No newline at end of file