Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Fix syntax warnings #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions azure-cosmosdb-table/doc/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand All @@ -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.
AtomPub, improving performance.
4 changes: 2 additions & 2 deletions azure-cosmosdb-table/tests/table/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
20 changes: 14 additions & 6 deletions azure-cosmosdb-table/tests/table/test_table_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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')
Expand All @@ -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)
Expand Down