Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 66860d0

Browse files
TestgresTests::test_ports_management is corrected
Let's send warning about a garbage in the container "bound_ports" and continue working.
1 parent e4e8909 commit 66860d0

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

tests/test_simple.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -918,20 +918,38 @@ def test_isolation_levels(self):
918918
con.begin('Garbage').commit()
919919

920920
def test_ports_management(self):
921-
# check that no ports have been bound yet
922-
assert (len(bound_ports) == 0)
921+
assert bound_ports is not None
922+
assert type(bound_ports) == set # noqa: E721
923+
924+
if len(bound_ports) != 0:
925+
logging.warning("bound_ports is not empty: {0}".format(bound_ports))
926+
927+
stage0__bound_ports = bound_ports.copy()
923928

924929
with get_new_node() as node:
925-
# check that we've just bound a port
926-
assert (len(bound_ports) == 1)
930+
assert bound_ports is not None
931+
assert type(bound_ports) == set # noqa: E721
932+
933+
assert node.port is not None
934+
assert type(node.port) == int # noqa: E721
935+
936+
logging.info("node port is {0}".format(node.port))
937+
938+
assert node.port in bound_ports
939+
assert node.port not in stage0__bound_ports
940+
941+
assert stage0__bound_ports <= bound_ports
942+
assert len(stage0__bound_ports) + 1 == len(bound_ports)
943+
944+
stage1__bound_ports = stage0__bound_ports.copy()
945+
stage1__bound_ports.add(node.port)
927946

928-
# check that bound_ports contains our port
929-
port_1 = list(bound_ports)[0]
930-
port_2 = node.port
931-
assert (port_1 == port_2)
947+
assert stage1__bound_ports == bound_ports
932948

933949
# check that port has been freed successfully
934-
assert (len(bound_ports) == 0)
950+
assert bound_ports is not None
951+
assert type(bound_ports) == set # noqa: E721
952+
assert bound_ports == stage0__bound_ports
935953

936954
def test_exceptions(self):
937955
str(StartNodeException('msg', [('file', 'lines')]))

0 commit comments

Comments
 (0)