-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f278865
commit 1da8ccb
Showing
2 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,11 +76,10 @@ def test_string_suffix_and_start(self): | |
assert next(sequence) == "[email protected]" | ||
|
||
def test_string_invalid_suffix(self): | ||
sequence = seq("cookie", suffix=42) | ||
|
||
with pytest.raises(TypeError) as exc: | ||
next(sequence) | ||
assert str(exc.value) == "Sequences suffix can only be a string" | ||
next(seq("cookie", suffix=42)) | ||
|
||
assert str(exc.value) == "Sequences suffix can only be a string" | ||
|
||
def test_int(self): | ||
sequence = seq(1) | ||
|
@@ -119,13 +118,12 @@ def test_float_increment_by(self): | |
assert next(sequence) == pytest.approx(6.63) | ||
|
||
def test_numbers_with_suffix(self): | ||
sequence = seq(1, suffix="iamnotanumber") | ||
with pytest.raises(TypeError) as exc: | ||
next(sequence) | ||
assert ( | ||
str(exc.value) | ||
== "Sequences with suffix can only be used with text values" | ||
) | ||
next(seq(1, suffix="iamnotanumber")) | ||
|
||
assert ( | ||
str(exc.value) == "Sequences with suffix can only be used with text values" | ||
) | ||
|
||
def test_date(self): | ||
sequence = seq( | ||
|
@@ -162,3 +160,20 @@ def test_datetime(self, settings, use_tz): | |
assert next(sequence) == datetime.datetime( | ||
2021, 2, 12, 00, 39, 58, 457698 | ||
).replace(tzinfo=tzinfo) | ||
|
||
@pytest.mark.parametrize( | ||
"value", | ||
[ | ||
datetime.datetime(2021, 2, 11, 15, 39, 58, 457698), | ||
datetime.date(2021, 2, 11), | ||
datetime.time(15, 39, 58, 457698), | ||
], | ||
) | ||
def test_should_raise_exception_for_datetime_instances(self, value): | ||
with pytest.raises(TypeError) as exc: | ||
next(seq(value)) | ||
|
||
assert str(exc.value) == ( | ||
"Sequences with values datetime.datetime, datetime.date and datetime.time, " | ||
"incremente_by must be a datetime.timedelta." | ||
) |