diff --git a/azure-cosmosdb-table/azure/cosmosdb/table/common/_connection.py b/azure-cosmosdb-table/azure/cosmosdb/table/common/_connection.py index 6836cf9..2dc6f22 100644 --- a/azure-cosmosdb-table/azure/cosmosdb/table/common/_connection.py +++ b/azure-cosmosdb-table/azure/cosmosdb/table/common/_connection.py @@ -79,7 +79,7 @@ def __init__(self, service, account_name=None, account_key=None, sas_token=None, path = parsed_url.path.rstrip('/') self.primary_endpoint = parsed_url.netloc + path - self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme + self.protocol = self.protocol if parsed_url.scheme == '' else parsed_url.scheme else: if not self.account_name: raise ValueError(_ERROR_STORAGE_MISSING_INFO) diff --git a/azure-cosmosdb-table/doc/upgrade.rst b/azure-cosmosdb-table/doc/upgrade.rst index 2696da9..48ac2fa 100644 --- a/azure-cosmosdb-table/doc/upgrade.rst +++ b/azure-cosmosdb-table/doc/upgrade.rst @@ -21,7 +21,7 @@ parameter values are divided by '_' between words as is idiomatic. Listing returns a generator rather than a result segment. This generator automatically follows continuation tokens as more results are requested. -SAS methods take several individual parameters rather than a single paramter +SAS methods take several individual parameters rather than a single parameter object. Similarly, ACL getters and setters take dictionaries mapping id to AccessPolicy rather than a list of SignedIdentifiers each holding an id and an AccessPolicy. @@ -66,7 +66,7 @@ Table Rather than having a boolean switch for turning batching on and off, batches are an object which can be populated and then committed. Entities can be sent as dictionaries or as Entity objects, and returned entities are accessible as either objects or -dictionaries. Methods which access and modify entites have been simplified so that +dictionaries. Methods which access and modify entities have been simplified so that if they take an entity object they extract the partition key and row key from that object rather than requiring these be sent separately. @@ -76,4 +76,4 @@ decided based on the size of the number, but this resulted in hard to predict types on the service. So, the more consistent option was chosen. Operations no longer echo content from the service and JSON is used instead of -AtomPub, improving performance. \ No newline at end of file +AtomPub, improving performance. diff --git a/azure-cosmosdb-table/tests/table/test_table.py b/azure-cosmosdb-table/tests/table/test_table.py index 5cd863e..bda7ef8 100644 --- a/azure-cosmosdb-table/tests/table/test_table.py +++ b/azure-cosmosdb-table/tests/table/test_table.py @@ -384,9 +384,9 @@ def test_account_sas(self): @record def test_locale(self): # Arrange - if os.name is "nt": + if os.name == "nt": culture = "Spanish_Spain" - elif os.name is 'posix': + elif os.name == 'posix': culture = 'es_ES.UTF-8' else: culture = 'es_ES.utf8' diff --git a/azure-cosmosdb-table/tests/table/test_table_entity.py b/azure-cosmosdb-table/tests/table/test_table_entity.py index 21d18d1..e0b2fff 100644 --- a/azure-cosmosdb-table/tests/table/test_table_entity.py +++ b/azure-cosmosdb-table/tests/table/test_table_entity.py @@ -79,6 +79,14 @@ def tearDown(self): return super(StorageTableEntityTest, self).tearDown() + # --Backward compatibility shims-------------------------------------------- + + def assertRaisesRegex(self, exception, message): + # assertRaisesRegexp deprecated and renamed to assertRaisesRegex in 3.1 + if hasattr(unittest.TestCase, 'assertRaisesRegex'): + return super(StorageTestCase, self).assertRaisesRegex(exception, message) + return super(StorageTestCase, self).assertRaisesRegexp(exception, message) + # --Helpers----------------------------------------------------------------- def _create_query_table(self, entity_count): @@ -347,12 +355,12 @@ def test_insert_entity_with_large_int32_value_throws(self): dict32['large'] = EntityProperty(EdmType.INT32, 2 ** 31) # Assert - with self.assertRaisesRegexp(TypeError, + with self.assertRaisesRegex(TypeError, '{0} is too large to be cast to type Edm.Int32.'.format(2 ** 31)): self.ts.insert_entity(self.table_name, dict32) dict32['large'] = EntityProperty(EdmType.INT32, -(2 ** 31 + 1)) - with self.assertRaisesRegexp(TypeError, + with self.assertRaisesRegex(TypeError, '{0} is too large to be cast to type Edm.Int32.'.format(-(2 ** 31 + 1))): self.ts.insert_entity(self.table_name, dict32) @@ -365,12 +373,12 @@ def test_insert_entity_with_large_int64_value_throws(self): dict64['large'] = EntityProperty(EdmType.INT64, 2 ** 63) # Assert - with self.assertRaisesRegexp(TypeError, + with self.assertRaisesRegex(TypeError, '{0} is too large to be cast to type Edm.Int64.'.format(2 ** 63)): self.ts.insert_entity(self.table_name, dict64) dict64['large'] = EntityProperty(EdmType.INT64, -(2 ** 63 + 1)) - with self.assertRaisesRegexp(TypeError, + with self.assertRaisesRegex(TypeError, '{0} is too large to be cast to type Edm.Int64.'.format(-(2 ** 63 + 1))): self.ts.insert_entity(self.table_name, dict64) @@ -520,7 +528,7 @@ def test_get_entity_with_property_resolver_not_supported(self): entity = self._insert_random_entity() # Act - with self.assertRaisesRegexp(AzureException, + with self.assertRaisesRegex(AzureException, 'Type not supported when sending data to the service:'): self.ts.get_entity(self.table_name, entity.PartitionKey, entity.RowKey, property_resolver=lambda pk, rk, name, val, type: 'badType') @@ -533,7 +541,7 @@ def test_get_entity_with_property_resolver_invalid(self): entity = self._insert_random_entity() # Act - with self.assertRaisesRegexp(AzureException, + with self.assertRaisesRegex(AzureException, 'The specified property resolver returned an invalid type.'): self.ts.get_entity(self.table_name, entity.PartitionKey, entity.RowKey, property_resolver=lambda pk, rk, name, val, type: EdmType.INT64)