-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
75 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Testing table.foreach() method. | ||
This is a **very dangerous** method, so it is tested separately. | ||
""" | ||
from ..tables import Table | ||
|
||
|
||
def test_tables() -> None: | ||
"""The actual tests.""" | ||
tbl = Table(1, 2, 3) | ||
assert isinstance(tbl.foreach(lambda x, y: y), | ||
list), "Foreach test 1 failed!" | ||
assert tbl.foreach(lambda x, y: [x, y, True]) == [ | ||
[0, 1, True], | ||
[1, 2, True], | ||
[2, 3, True] | ||
], "Foreach test 2 failed!" |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Testing list and dict methods of tables""" | ||
from ..tables import Table | ||
|
||
def test_inheritance() -> None: | ||
"""The actual tests. | ||
Returns: | ||
Optional[bool]: True or None if the test passes, False or errors if it fails. | ||
""" | ||
assert Table(1,3,2).sort() == Table(1,2,3), "Inheritance test 1 failed!" | ||
assert bool(Table(1,2,3)), "Inheritance test 2 failed!" | ||
assert not bool(Table()), "Inheritance test 3 failed!" | ||
assert Table(1,2,3).list == [1,2,3], "Inheritance test 4 failed!" | ||
assert Table(1,2,3).dict == {}, "Inheritance test 5 failed!" | ||
x = Table(1,2,3) | ||
assert x.pop(1) == 2, "Inheritance test 6 failed!" | ||
assert x == Table(1,3), "Inheritance test 7 failed!" |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Testing table operands, like +, ==, etc.""" | ||
from ..tables import Table | ||
|
||
|
||
def test_operands() -> None: | ||
"""The actual tests.""" | ||
assert Table() + Table() == Table(), "Operands test 1 failed!" | ||
assert Table(1, 2, 3) + Table(4, 5, 6) == Table(1, 2, | ||
3, 4, 5, 6), "Operands test 2 failed!" | ||
assert Table(1, 2, 3) != Table( | ||
1, 2, 3, foo="bar"), "Operands test 3 failed!" | ||
assert Table(1, 2, 3) == Table(1, 2, 3), "Operands test 4 failed!" | ||
assert Table(1, 2, 3) != Table(1, 2, 4), "Operands test 5 failed!" | ||
assert Table(foo="bar") == Table(foo="bar"), "Operands test 6 failed!" | ||
assert Table(foo="bar") != Table(foo="baz"), "Operands test 7 failed!" | ||
assert Table(1, 2, 3) + Table(foo="bar") == Table(1, 2, | ||
3, foo="bar"), "Operands test 8 failed!" | ||
x = Table() | ||
x.append(2) | ||
x["foo"] = "bar" | ||
assert x == Table(2, foo="bar"), "Operands test 9 failed!" | ||
assert id(x) != id(Table(2, foo="bar")), "Operands test 10 failed!" |