summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2019-11-04 18:34:07 -0800
committerBenjamin Peterson <benjamin@python.org>2019-11-04 18:34:07 -0800
commit10538f7217d7aad3976bb379f6af3187da61eb30 (patch)
tree304421e3f19dc5861ee3c3e92a7bbea8c14f29f3
parentebb0db59f8cc221209876307d069c7c204fbb69a (diff)
downloadsix-git-10538f7217d7aad3976bb379f6af3187da61eb30.tar.gz
py.test -> pytest
-rw-r--r--.travis.yml2
-rw-r--r--test_six.py92
2 files changed, 47 insertions, 47 deletions
diff --git a/.travis.yml b/.travis.yml
index 3425ecc..ccf7f0f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,7 @@ install:
- pip install pytest typing
- &py_pkg_list pip list --format=columns || pip list
script:
-- py.test
+- pytest
- echo Checking whether installation flow is not broken...
- pip uninstall --yes six || true
- pip install --ignore-installed .
diff --git a/test_six.py b/test_six.py
index d175683..0b72067 100644
--- a/test_six.py
+++ b/test_six.py
@@ -24,7 +24,7 @@ import types
import unittest
import abc
-import py
+import pytest
import six
@@ -81,7 +81,7 @@ def test_MAXSIZE():
except AttributeError:
# Before Python 2.6.
pass
- py.test.raises(
+ pytest.raises(
(ValueError, OverflowError),
operator.mul, [None], six.MAXSIZE + 1)
@@ -113,7 +113,7 @@ except ImportError:
except ImportError:
have_gdbm = False
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._moved_attributes])
def test_move_items(item_name):
"""Ensure that everything loads correctly."""
@@ -123,36 +123,36 @@ def test_move_items(item_name):
__import__("six.moves." + item_name)
except AttributeError:
if item_name == "zip_longest" and sys.version_info < (2, 6):
- py.test.skip("zip_longest only available on 2.6+")
+ pytest.skip("zip_longest only available on 2.6+")
except ImportError:
if item_name == "winreg" and not sys.platform.startswith("win"):
- py.test.skip("Windows only module")
+ pytest.skip("Windows only module")
if item_name.startswith("tkinter"):
if not have_tkinter:
- py.test.skip("requires tkinter")
+ pytest.skip("requires tkinter")
if item_name == "tkinter_ttk" and sys.version_info[:2] <= (2, 6):
- py.test.skip("ttk only available on 2.7+")
+ pytest.skip("ttk only available on 2.7+")
if item_name.startswith("dbm_gnu") and not have_gdbm:
- py.test.skip("requires gdbm")
+ pytest.skip("requires gdbm")
raise
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves)
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_parse_moved_attributes])
def test_move_items_urllib_parse(item_name):
"""Ensure that everything loads correctly."""
if item_name == "ParseResult" and sys.version_info < (2, 5):
- py.test.skip("ParseResult is only found on 2.5+")
+ pytest.skip("ParseResult is only found on 2.5+")
if item_name in ("parse_qs", "parse_qsl") and sys.version_info < (2, 6):
- py.test.skip("parse_qs[l] is new in 2.6")
+ pytest.skip("parse_qs[l] is new in 2.6")
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.parse)
getattr(six.moves.urllib.parse, item_name)
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_error_moved_attributes])
def test_move_items_urllib_error(item_name):
"""Ensure that everything loads correctly."""
@@ -161,7 +161,7 @@ def test_move_items_urllib_error(item_name):
getattr(six.moves.urllib.error, item_name)
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_request_moved_attributes])
def test_move_items_urllib_request(item_name):
"""Ensure that everything loads correctly."""
@@ -170,7 +170,7 @@ def test_move_items_urllib_request(item_name):
getattr(six.moves.urllib.request, item_name)
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_response_moved_attributes])
def test_move_items_urllib_response(item_name):
"""Ensure that everything loads correctly."""
@@ -179,7 +179,7 @@ def test_move_items_urllib_response(item_name):
getattr(six.moves.urllib.response, item_name)
-@py.test.mark.parametrize("item_name",
+@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_robotparser_moved_attributes])
def test_move_items_urllib_robotparser(item_name):
"""Ensure that everything loads correctly."""
@@ -244,7 +244,7 @@ def test_zip():
assert six.advance_iterator(zip(range(2), range(2))) == (0, 0)
-@py.test.mark.skipif("sys.version_info < (2, 6)")
+@pytest.mark.skipif("sys.version_info < (2, 6)")
def test_zip_longest():
from six.moves import zip_longest
it = zip_longest(range(2), range(1))
@@ -322,7 +322,7 @@ class TestCustomizedMoves:
def test_empty_remove(self):
- py.test.raises(AttributeError, six.remove_move, "eggs")
+ pytest.raises(AttributeError, six.remove_move, "eggs")
def test_get_unbound_function():
@@ -338,7 +338,7 @@ def test_get_method_self():
pass
x = X()
assert six.get_method_self(x.m) is x
- py.test.raises(AttributeError, six.get_method_self, 42)
+ pytest.raises(AttributeError, six.get_method_self, 42)
def test_get_method_function():
@@ -347,7 +347,7 @@ def test_get_method_function():
pass
x = X()
assert six.get_method_function(x.m) is X.__dict__["m"]
- py.test.raises(AttributeError, six.get_method_function, hasattr)
+ pytest.raises(AttributeError, six.get_method_function, hasattr)
def test_get_function_closure():
@@ -365,7 +365,7 @@ def test_get_function_code():
pass
assert isinstance(six.get_function_code(f), types.CodeType)
if not hasattr(sys, "pypy_version_info"):
- py.test.raises(AttributeError, six.get_function_code, hasattr)
+ pytest.raises(AttributeError, six.get_function_code, hasattr)
def test_get_function_defaults():
@@ -405,7 +405,7 @@ def test_dictionary_iterators(monkeypatch):
it = meth(d)
assert not isinstance(it, list)
assert list(it) == list(getattr(d, name)())
- py.test.raises(StopIteration, six.advance_iterator, it)
+ pytest.raises(StopIteration, six.advance_iterator, it)
record = []
def with_kw(*args, **kw):
record.append(kw["kw"])
@@ -417,7 +417,7 @@ def test_dictionary_iterators(monkeypatch):
monkeypatch.undo()
-@py.test.mark.skipif("sys.version_info[:2] < (2, 7)",
+@pytest.mark.skipif("sys.version_info[:2] < (2, 7)",
reason="view methods on dictionaries only available on 2.7+")
def test_dictionary_views():
def stock_method_name(viewwhat):
@@ -441,8 +441,8 @@ def test_advance_iterator():
it = iter(l)
assert six.next(it) == 1
assert six.next(it) == 2
- py.test.raises(StopIteration, six.next, it)
- py.test.raises(StopIteration, six.next, it)
+ pytest.raises(StopIteration, six.next, it)
+ pytest.raises(StopIteration, six.next, it)
def test_iterator():
@@ -490,7 +490,7 @@ def test_create_unbound_method():
def f(self):
return self
u = six.create_unbound_method(f, X)
- py.test.raises(TypeError, u)
+ pytest.raises(TypeError, u)
if six.PY2:
assert isinstance(u, types.MethodType)
x = X()
@@ -538,13 +538,13 @@ def test_unichr():
def test_int2byte():
assert six.int2byte(3) == six.b("\x03")
- py.test.raises(Exception, six.int2byte, 256)
+ pytest.raises(Exception, six.int2byte, 256)
def test_byte2int():
assert six.byte2int(six.b("\x03")) == 3
assert six.byte2int(six.b("\x03\x04")) == 3
- py.test.raises(IndexError, six.byte2int, six.b(""))
+ pytest.raises(IndexError, six.byte2int, six.b(""))
def test_bytesindex():
@@ -555,7 +555,7 @@ def test_bytesiter():
it = six.iterbytes(six.b("hi"))
assert six.next(it) == ord("h")
assert six.next(it) == ord("i")
- py.test.raises(StopIteration, six.next, it)
+ pytest.raises(StopIteration, six.next, it)
def test_StringIO():
@@ -690,7 +690,7 @@ def test_print_():
assert out.flushed
-@py.test.mark.skipif("sys.version_info[:2] >= (2, 6)")
+@pytest.mark.skipif("sys.version_info[:2] >= (2, 6)")
def test_print_encoding(monkeypatch):
# Fool the type checking in print_.
monkeypatch.setattr(six, "file", six.BytesIO, raising=False)
@@ -702,16 +702,16 @@ def test_print_encoding(monkeypatch):
out = six.BytesIO()
out.encoding = "ascii"
out.errors = "strict"
- py.test.raises(UnicodeEncodeError, six.print_, six.u("\u053c"), file=out)
+ pytest.raises(UnicodeEncodeError, six.print_, six.u("\u053c"), file=out)
out.errors = "backslashreplace"
six.print_(six.u("\u053c"), end="", file=out)
assert out.getvalue() == six.b("\\u053c")
def test_print_exceptions():
- py.test.raises(TypeError, six.print_, x=3)
- py.test.raises(TypeError, six.print_, end=3)
- py.test.raises(TypeError, six.print_, sep=42)
+ pytest.raises(TypeError, six.print_, x=3)
+ pytest.raises(TypeError, six.print_, end=3)
+ pytest.raises(TypeError, six.print_, sep=42)
def test_with_metaclass():
@@ -745,12 +745,12 @@ def test_with_metaclass():
assert Y.__mro__ == (Y, X, object)
-@py.test.mark.skipif("sys.version_info[:2] < (2, 7)")
+@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_with_metaclass_typing():
try:
import typing
except ImportError:
- py.test.skip("typing module required")
+ pytest.skip("typing module required")
class Meta(type):
pass
if sys.version_info[:2] < (3, 7):
@@ -770,7 +770,7 @@ def test_with_metaclass_typing():
assert G.__orig_bases__ == (typing.Generic[T],)
-@py.test.mark.skipif("sys.version_info[:2] < (3, 7)")
+@pytest.mark.skipif("sys.version_info[:2] < (3, 7)")
def test_with_metaclass_pep_560():
class Meta(type):
pass
@@ -792,7 +792,7 @@ def test_with_metaclass_pep_560():
assert G.__orig_bases__ == (fake,)
-@py.test.mark.skipif("sys.version_info[:2] < (3, 0)")
+@pytest.mark.skipif("sys.version_info[:2] < (3, 0)")
def test_with_metaclass_prepare():
"""Test that with_metaclass causes Meta.__prepare__ to be called with the correct arguments."""
@@ -905,7 +905,7 @@ def test_add_metaclass():
assert MySlots.__slots__ == ["a", "b"]
instance = MySlots()
instance.a = "foo"
- py.test.raises(AttributeError, setattr, instance, "c", "baz")
+ pytest.raises(AttributeError, setattr, instance, "c", "baz")
# Test a class with string for slots.
class MyStringSlots(object):
@@ -914,8 +914,8 @@ def test_add_metaclass():
assert MyStringSlots.__slots__ == "ab"
instance = MyStringSlots()
instance.ab = "foo"
- py.test.raises(AttributeError, setattr, instance, "a", "baz")
- py.test.raises(AttributeError, setattr, instance, "b", "baz")
+ pytest.raises(AttributeError, setattr, instance, "a", "baz")
+ pytest.raises(AttributeError, setattr, instance, "b", "baz")
class MySlotsWeakref(object):
__slots__ = "__weakref__",
@@ -923,7 +923,7 @@ def test_add_metaclass():
assert type(MySlotsWeakref) is Meta
-@py.test.mark.skipif("sys.version_info[:2] < (3, 3)")
+@pytest.mark.skipif("sys.version_info[:2] < (3, 3)")
def test_add_metaclass_nested():
# Regression test for https://github.com/benjaminp/six/issues/259
class Meta(type):
@@ -943,7 +943,7 @@ def test_add_metaclass_nested():
assert A.B.__qualname__ == expected
-@py.test.mark.skipif("sys.version_info[:2] < (2, 7) or sys.version_info[:2] in ((3, 0), (3, 1))")
+@pytest.mark.skipif("sys.version_info[:2] < (2, 7) or sys.version_info[:2] in ((3, 0), (3, 1))")
def test_assertCountEqual():
class TestAssertCountEqual(unittest.TestCase):
def test(self):
@@ -955,7 +955,7 @@ def test_assertCountEqual():
TestAssertCountEqual('test').test()
-@py.test.mark.skipif("sys.version_info[:2] < (2, 7)")
+@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_assertRegex():
class TestAssertRegex(unittest.TestCase):
def test(self):
@@ -967,7 +967,7 @@ def test_assertRegex():
TestAssertRegex('test').test()
-@py.test.mark.skipif("sys.version_info[:2] < (2, 7)")
+@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_assertRaisesRegex():
class TestAssertRaisesRegex(unittest.TestCase):
def test(self):
@@ -1009,12 +1009,12 @@ class EnsureTests:
BINARY_EMOJI = b"\xf0\x9f\x98\x80"
def test_ensure_binary_raise_type_error(self):
- with py.test.raises(TypeError):
+ with pytest.raises(TypeError):
six.ensure_str(8)
def test_errors_and_encoding(self):
six.ensure_binary(self.UNICODE_EMOJI, encoding='latin-1', errors='ignore')
- with py.test.raises(UnicodeEncodeError):
+ with pytest.raises(UnicodeEncodeError):
six.ensure_binary(self.UNICODE_EMOJI, encoding='latin-1', errors='strict')
def test_ensure_binary_raise(self):