def test_idmaker_autoname(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [("string", 1.0), ("st-ring", 2.0)]) assert result == ["string-1.0", "st-ring-2.0"] result = idmaker(("a", "b"), [(object(), 1.0), (object(), object())]) assert result == ["a0-1.0", "a1-b1"]
def test_idmaker_autoname(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [("string", 1.0), ("st-ring", 2.0)]) assert result == ["string-1.0", "st-ring-2.0"] result = idmaker(("a", "b"), [(object(), 1.0), (object(), object())]) assert result == ["a0-1.0", "a1-b1"]
def test_idmaker_autoname(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [("string", 1.0), ("st-ring", 2.0)]) assert result == ["string-1.0", "st-ring-2.0"] result = idmaker(("a", "b"), [(object(), 1.0), (object(), object())]) assert result == ["a0-1.0", "a1-b1"] # unicode mixing, issue250 result = idmaker((py.builtin._totext("a"), "b"), [({}, '\xc3\xb4')]) assert result == ['a0-\xc3\xb4']
def test_idmaker_autoname(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [("string", 1.0), ("st-ring", 2.0)]) assert result == ["string-1.0", "st-ring-2.0"] result = idmaker(("a", "b"), [(object(), 1.0), (object(), object())]) assert result == ["a0-1.0", "a1-b1"] # unicode mixing, issue250 result = idmaker((py.builtin._totext("a"), "b"), [({}, b"\xc3\xb4")]) assert result == ["a0-\\xc3\\xb4"]
def test_idmaker_native_strings(self): from _pytest.python import idmaker totext = py.builtin._totext result = idmaker( ("a", "b"), [ (1.0, -1.1), (2, -202), ("three", "three hundred"), (True, False), (None, None), (re.compile("foo"), re.compile("bar")), (str, int), (list("six"), [66, 66]), (set([7]), set("seven")), (tuple("eight"), (8, -8, 8)), (b"\xc3\xb4", b"name"), (b"\xc3\xb4", totext("other")), ], ) assert result == [ "1.0--1.1", "2--202", "three-three hundred", "True-False", "None-None", "foo-bar", "str-int", "a7-b7", "a8-b8", "a9-b9", "\\xc3\\xb4-name", "\\xc3\\xb4-other", ]
def test_idmaker_enum(self): from _pytest.python import idmaker enum = pytest.importorskip("enum") e = enum.Enum("Foo", "one, two") result = idmaker(("a", "b"), [(e.one, e.two)]) assert result == ["Foo.one-Foo.two"]
def test_idmaker_native_strings(self): from _pytest.python import idmaker totext = py.builtin._totext result = idmaker(("a", "b"), [(1.0, -1.1), (2, -202), ("three", "three hundred"), (True, False), (None, None), (re.compile('foo'), re.compile('bar')), (str, int), (list("six"), [66, 66]), (set([7]), set("seven")), (tuple("eight"), (8, -8, 8)), (b'\xc3\xb4', b"name"), (b'\xc3\xb4', totext("other")), ]) assert result == ["1.0--1.1", "2--202", "three-three hundred", "True-False", "None-None", "foo-bar", "str-int", "a7-b7", "a8-b8", "a9-b9", "\\xc3\\xb4-name", "\\xc3\\xb4-other", ]
def test_idmaker_idfn_unique_names(self): from _pytest.python import idmaker def ids(val): return "a" result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3])], idfn=ids) assert result == ["0a-a", "1a-a", "2a-a"]
def test_idmaker_idfn_exception(self): from _pytest.python import idmaker def ids(val): raise Exception("bad code") result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3])], idfn=ids) assert result == ["10.0-b0", "20-b1", "three-b2"]
def test_idmaker_idfn(self): from _pytest.python import idmaker def ids(val): if isinstance(val, Exception): return repr(val) result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3])], idfn=ids) assert result == ["10.0-IndexError()", "20-KeyError()", "three-b2"]
def test_idmaker_native_strings(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [(1.0, -1.1), (2, -202), ("three", "three hundred"), (True, False), (None, None), (list("six"), [66, 66]), (set([7]), set("seven")), (tuple("eight"), (8, -8, 8))]) assert result == [ "1.0--1.1", "2--202", "three-three hundred", "True-False", "None-None", "a5-b5", "a6-b6", "a7-b7" ]
def test_idmaker_idfn_unique_names(self): from _pytest.python import idmaker def ids(val): return 'a' result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3]), ], idfn=ids) assert result == ["a-a0", "a-a1", "a-a2", ]
def test_idmaker_idfn_exception(self): from _pytest.python import idmaker def ids(val): raise Exception("bad code") result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3]), ], idfn=ids) assert result == ["10.0-b0", "20-b1", "three-b2", ]
def test_idmaker_idfn(self): from _pytest.python import idmaker def ids(val): if isinstance(val, Exception): return repr(val) result = idmaker(("a", "b"), [(10.0, IndexError()), (20, KeyError()), ("three", [1, 2, 3]), ], idfn=ids) assert result == ["10.0-IndexError()", "20-KeyError()", "three-b2", ]
def test_idmaker_native_strings(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [(1.0, -1.1), (2, -202), ("three", "three hundred"), (True, False), (None, None), (list("six"), [66, 66]), (set([7]), set("seven")), (tuple("eight"), (8, -8, 8)) ]) assert result == ["1.0--1.1", "2--202", "three-three hundred", "True-False", "None-None", "a5-b5", "a6-b6", "a7-b7"]
def test_idmaker_native_strings(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [(1.0, -1.1), (2, -202), ("three", "three hundred"), (True, False), (None, None), (re.compile('foo'), re.compile('bar')), (str, int), (list("six"), [66, 66]), (set([7]), set("seven")), (tuple("eight"), (8, -8, 8)) ]) assert result == ["1.0--1.1", "2--202", "three-three hundred", "True-False", "None-None", "foo-bar", "str-int", "a7-b7", "a8-b8", "a9-b9"]
def test_idmaker_with_ids_unique_names(self): from _pytest.python import idmaker result = idmaker(("a"), [1,2,3,4,5], ids=["a", "a", "b", "c", "b"]) assert result == ["a0", "a1", "b0", "c", "b1"]
def test_idmaker_with_bytes_regex(self): from _pytest.python import idmaker result = idmaker(("a"), [(re.compile(b'foo'), 1.0)]) assert result == ["foo"]
def test_idmaker_enum(self): from _pytest.python import idmaker enum = pytest.importorskip("enum") e = enum.Enum("Foo", "one, two") result = idmaker(("a", "b"), [(e.one, e.two)]) assert result == ["Foo.one-Foo.two"]
def test_idmaker_with_ids(self): from _pytest.python import idmaker result = idmaker(("a", "b"), [(1, 2), (3, 4)], ids=["a", None]) assert result == ["a", "3-4"]