From a2469257580c74ca0d5bcf643fc95a1f24038a99 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 4 Jan 2025 19:11:11 -0400 Subject: [PATCH] Remove is It does not match orthodox python style. And trigger warnings: cqlengine/query/test_queryoperators.py:157: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? self.assertTrue(len(first_page) is 1) --- tests/integration/cqlengine/__init__.py | 6 +++--- tests/integration/cqlengine/query/test_queryoperators.py | 4 ++-- tests/integration/standard/test_connection.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/cqlengine/__init__.py b/tests/integration/cqlengine/__init__.py index 5b7d16c53..204dcb125 100644 --- a/tests/integration/cqlengine/__init__.py +++ b/tests/integration/cqlengine/__init__.py @@ -77,10 +77,10 @@ def wrapped_function(*args, **kwargs): # DeMonkey Patch our code cassandra.cqlengine.connection.execute = original_function # Check to see if we have a pre-existing test case to work from. - if len(args) is 0: - test_case = unittest.TestCase("__init__") - else: + if args: test_case = args[0] + else: + test_case = unittest.TestCase("__init__") # Check to see if the count is what you expect test_case.assertEqual(count.get_counter(), expected, msg="Expected number of cassandra.cqlengine.connection.execute calls ({0}) doesn't match actual number invoked ({1})".format(expected, count.get_counter())) return to_return diff --git a/tests/integration/cqlengine/query/test_queryoperators.py b/tests/integration/cqlengine/query/test_queryoperators.py index fd148bafc..fbf666cf2 100644 --- a/tests/integration/cqlengine/query/test_queryoperators.py +++ b/tests/integration/cqlengine/query/test_queryoperators.py @@ -154,6 +154,6 @@ def test_named_table_pk_token_function(self): query = named.all().limit(1) first_page = list(query) last = first_page[-1] - self.assertTrue(len(first_page) is 1) + self.assertTrue(len(first_page) == 1) next_page = list(query.filter(pk__token__gt=functions.Token(last.key))) - self.assertTrue(len(next_page) is 1) + self.assertTrue(len(next_page) == 1) diff --git a/tests/integration/standard/test_connection.py b/tests/integration/standard/test_connection.py index bcc133781..4d388ed23 100644 --- a/tests/integration/standard/test_connection.py +++ b/tests/integration/standard/test_connection.py @@ -182,7 +182,7 @@ def wait_for_connections(self, host, cluster): while(retry < 300): retry += 1 connections = self.fetch_connections(host, cluster) - if len(connections) is not 0: + if connections: return connections time.sleep(.1) self.fail("No new connections found") @@ -192,7 +192,7 @@ def wait_for_no_connections(self, host, cluster): while(retry < 100): retry += 1 connections = self.fetch_connections(host, cluster) - if len(connections) is 0: + if not connections: return time.sleep(.5) self.fail("Connections never cleared")