Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: google/apitools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.16
Choose a base ref
...
head repository: google/apitools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Aug 22, 2017

  1. Fix a bad bounds check for downloads.

    Previously, if we created a download with `auto_transfer=True` with the full
    download smaller than the default `chunksize`, and then called
    `StreamInChunks`, we'd end up downloading the full content twice. This was due
    to a bad bounds check in setting a range header -- we'd end up with a header
    like `Range: bytes=100-99`, and the server would ignore the start value,
    giving us all the bytes again.
    
    This adds a fix and a test.
    craigcitro committed Aug 22, 2017
    Copy the full SHA
    9e706f9 View commit details

Commits on Oct 4, 2017

  1. Change encoding.DictToProtoMap() to match how AdditionalProperty mess…

    …ages are used in practice, and rename the method to better reflect what it does.
    kevinli7 committed Oct 4, 2017
    Copy the full SHA
    787e53f View commit details
  2. Merge pull request #181 from kevinli7/master

    Change encoding.DictToProtoMap() to match how AdditionalProperty messages are used in practice, and rename the method to better reflect what it does.
    cherba29 authored Oct 4, 2017
    Copy the full SHA
    91d2506 View commit details

Commits on Oct 26, 2017

  1. Merge pull request #174 from craigcitro/bounds

    Fix a bad bounds check for downloads.
    vilasj authored Oct 26, 2017
    Copy the full SHA
    1c640d9 View commit details

Commits on Nov 1, 2017

  1. Add compression support

    mooman219 authored and houglum committed Nov 1, 2017
    Copy the full SHA
    0048271 View commit details
  2. Merge pull request #182 from mooman219/feature-compression

    Add compression support for streams
    
    Adds functionality necessary to compress streamed data on the fly, allowing for sending data in a compressed form (e.g. using the "Content-Encoding" HTTP header).  Applies compression only for chunked streams, compressing each chunk as it is streamed in.
    houglum committed Nov 1, 2017
    Copy the full SHA
    b9bdee9 View commit details

Commits on Nov 7, 2017

  1. Add simple upload compression support. (#183)

    Add simple upload compression support. Refactor compression flags for easier configuration during initialization.
    mooman219 authored and houglum committed Nov 7, 2017
    Copy the full SHA
    57873d8 View commit details

Commits on Nov 8, 2017

  1. Update for v0.5.17 release

    thobrla committed Nov 8, 2017
    Copy the full SHA
    4220ed9 View commit details

Commits on Nov 16, 2017

  1. Update client to accommodate oauth2client>=4.0 (#184)

    This changes has been needed for a while now. The main blocker
    seems to be the use of locked_file for caching GCE credentials.
    I've added a simple multiprocess lockable file cache that uses
    a similar approach to that used in ouath2client's multiprocess
    file storage.
    
    Submission of this should close issue #162.
    eap authored and craigcitro committed Nov 16, 2017
    Copy the full SHA
    63e97c1 View commit details

Commits on Nov 17, 2017

  1. Close out the rest of oauth compatibility issues (#186)

    * Update client to accommodate oauth2client>=4.0
    
    This changes has been needed for a while now. The main blocker
    seems to be the use of locked_file for caching GCE credentials.
    I've added a simple multiprocess lockable file cache that uses
    a similar approach to that used in ouath2client's multiprocess
    file storage.
    
    Submission of this should close issue #162.
    
    * Update test runner setup
    eap authored and craigcitro committed Nov 17, 2017
    Copy the full SHA
    cbf9c60 View commit details

Commits on Nov 20, 2017

  1. App Engine: add thread-only fallback to process locks. (#187)

    * App Engine: add thread-only fallback to process locks.
    
    * Respond to review comments
    eap authored and craigcitro committed Nov 20, 2017
    Copy the full SHA
    9c954cd View commit details

Commits on Nov 28, 2017

  1. Fix issue with copying unrecognized Enum values (#188)

    Before, this resulted in an error on decoding; now, it succeeds.
    
    I removed the comment about deleting the CopyProtoMessage function since
    (1) there's uses of the function both internally and by users of
    apitools, and (2) it's clearly non-trivial to correctly copy a proto
    message.
    znewman01 authored and craigcitro committed Nov 28, 2017
    Copy the full SHA
    48e438b View commit details

Commits on Dec 6, 2017

  1. Fix issue where uploading files would hang if a request failed while …

    …using stream_slice.StreamSlice.
    kevinli7 authored and vilasj committed Dec 6, 2017
    3
    Copy the full SHA
    7ccade5 View commit details
  2. Additional compression comments

    mooman219 authored and vilasj committed Dec 6, 2017
    Copy the full SHA
    dd457ed View commit details
  3. Update for v0.5.18 release.

    kevinli7 committed Dec 6, 2017
    Copy the full SHA
    d137b43 View commit details
  4. Merge pull request #190 from kevinli7/master

    Update for v0.5.18 release.
    kevinli7 authored Dec 6, 2017
    Copy the full SHA
    6836d47 View commit details

Commits on Dec 8, 2017

  1. Fix issue where the stream was being read in StreamMedia() where it

    shouldn't have.
    kevinli7 authored and vilasj committed Dec 8, 2017
    Copy the full SHA
    7333bbf View commit details
  2. Revert change to transfer.Upload that converts streams into strings i…

    …n StreamInChunks due to memory concerns. (#193)
    kevinli7 authored and houglum committed Dec 8, 2017
    Copy the full SHA
    1f8bbe5 View commit details
  3. Update for v0.5.19 release.

    kevinli7 committed Dec 8, 2017
    Copy the full SHA
    1c1efce View commit details
  4. Merge pull request #194 from kevinli7/master

    Update for v0.5.19 release.
    kevinli7 authored Dec 8, 2017
    Copy the full SHA
    b1c9c71 View commit details

Commits on Dec 15, 2017

  1. Fix GCE creds serialization w/ oauth2client >= 4.0 (#195)

    Fix GCE creds serialization w/ oauth2client >= 4.0
    
    When updating gsutil to use oauth2client 4.1.2 and apitools 0.5.19,
    testing on GCE instances showed that GceAssertionCredentials were not
    being written to our credential storage file. Debugging showed that this
    was because of a KeyError when looking for the 'scope' attribute in a
    serialized credential (no longer included as of oauth2client 3.0). This
    change maintains backward compatibility for oauth2client versions that
    used the 'scope' attribute while also working for current versions that
    don't include 'scope' when constructing a GceAssertionCredentials
    object.
    houglum authored Dec 15, 2017
    Copy the full SHA
    91a8932 View commit details

Commits on Dec 18, 2017

  1. Update for v0.5.20 release.

    houglum committed Dec 18, 2017
    Copy the full SHA
    2c0aef2 View commit details

Commits on Dec 21, 2017

  1. Copy the full SHA
    8d187a8 View commit details
  2. Merge pull request #197 from kevinli7/update-pypi

    Update home page in setup.py to point to the google repo.
    kevinli7 authored Dec 21, 2017
    Copy the full SHA
    4a3dfa2 View commit details

Commits on Jan 4, 2018

  1. Copy the full SHA
    3cca793 View commit details
  2. Merge pull request #198 from kevinli7/transfer-fix

    Fix issue where resumable uploads weren't resuming correctly on 500s.
    kevinli7 authored Jan 4, 2018
    Copy the full SHA
    8f99093 View commit details

Commits on Jan 16, 2018

  1. Update for v0.5.21 release.

    houglum committed Jan 16, 2018
    Copy the full SHA
    2bfa257 View commit details

Commits on Mar 6, 2018

  1. Fix issue with encoding unrecognized Enum values.

    Previously this caused an error when the Enum values were inside
    an unknown field because the base protojson codec used to copy the message
    during the mapping of unknown fields fails on unknown Enums. This changes
    the base protojson to handle unknown values for EnumFields as
    unrecognized fields.
    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    1414e04 View commit details
  2. Fix lint errors.

    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    e1300ce View commit details
  3. Fix dropped variable.

    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    48ebf5f View commit details
  4. Eliminate some unnecessary line breaks.

    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    f2f5baa View commit details
  5. Fix lint error.

    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    b11884f View commit details
  6. Add test for invalid message decoding.

    khtg authored and vilasj committed Mar 6, 2018
    Copy the full SHA
    ac71613 View commit details

Commits on Mar 7, 2018

  1. Fixing crash on Python 3 when batch_size is set to None in the list p…

    …ager (#203)
    
    Fixing crash on Python 3 when batch_size is set to None in the list pager
    markpell authored Mar 7, 2018
    Copy the full SHA
    da2e038 View commit details

Commits on Mar 8, 2018

  1. Copy the full SHA
    443c0fb View commit details
  2. Update for v0.5.22 release.

    khtg committed Mar 8, 2018
    Copy the full SHA
    ba6047a View commit details
  3. Merge pull request #205 from khtg/release0522

    Update for v0.5.22 release.
    khtg authored Mar 8, 2018
    Copy the full SHA
    6a2e91f View commit details

Commits on Mar 12, 2018

  1. Added response_encoding parameter to api client classes. (#206)

    On Python 3, httplib2 returns message contents as bytes, which cannot be
    read by json.loads(). It must first be decoded to text. Specifying this
    parameter tells the client to first decode the body before trying to
    parse it.
    markpell authored Mar 12, 2018
    Copy the full SHA
    fd4a7b7 View commit details

Commits on Mar 29, 2018

  1. Fix lint errors in apitools.

    This makes a few updates to get the linter happy:
    
    * drop oauth2l and oauth2l_test
    * add some newlines
    * fix formatting in two error messages
    * switch `pep8` -> `pycodestyle`
    * drop the custom pylintrc and `run_pylint`.
    
    The "have a custom system for pylint" seemed like a good idea long ago, but
    python linting tools have come far enough that it's more work than it's worth.
    craigcitro committed Mar 29, 2018
    Copy the full SHA
    4857df3 View commit details
  2. exclude samples & tests from install

    There's no value in installing the sample modules (plus they pollute
    the global samples.* namespace), nor in installing the unittests.
    
    For the samples, we set the include option with find_packages so the
    code only searches the top level apitools dir.
    
    For the tests, because they live alongside modules vs a completely
    sep tree (which is fine), we have to add a series of globs to the
    exclude_package_data to filter them out.
    vapier committed Mar 29, 2018
    Copy the full SHA
    a65ff69 View commit details
  3. Merge pull request #209 from craigcitro/lint

    Fix lint errors in apitools.
    kevinli7 authored Mar 29, 2018
    Copy the full SHA
    286e63d View commit details
  4. Drop all code related to generating CLIs.

    All of the generated CLI code depends on google-apputils, which is a
    python2.7-only library. Given that no one is directly using the generated CLIs
    right now, there's no point in porting it to (say) argparse.
    
    Fixes #8.
    
    The bulk of the change here is just deletion; I suspect there are now more
    dangling references, so some tree-shaking/dead-code-elimination could be
    fruitful. Other changes:
    
    * the client generation test now ensures each client can be imported, as
      opposed to invoking `<generated_cli> --help`.
    * the samples and sample generating script drop the CLIs.
    
    Note that I *did* keep the flag for `gen_client`, so that any existing code
    passing `--nogenerate_cli` wouldn't be broken.
    craigcitro committed Mar 29, 2018
    Copy the full SHA
    ed6f279 View commit details
  5. Ensure client generation works smoothly in py3.

    It turns out that generated clients had a few issues in python3:
    
    * the discovery doc was returned as bytes, but `json.loads` wanted a string
    * in python3, source files should be strings, not bytes
    * \N, \u, and \U have special interpretations in python3 strings, which makes
      them invalid bare sequences in a docstring.
    
    This commit updates these and re-enables tests for python3. The only remaining
    py2-only check is the "did we generate the exact same source file" check,
    which fails for trivial reasons (eg u'foo' vs. 'foo') for python3.
    
    Since there are no more python27-only tests, I removed the "disable test in
    2.7" helper.
    craigcitro committed Mar 29, 2018
    Copy the full SHA
    d475ca9 View commit details

Commits on Apr 3, 2018

  1. Add a function for detecting unrecognized fields.

    If this decoding library is used for parsing user input, an unrecognized
    field is very frequently a typo/error and the library should offer an
    interface to treat them as such. Without any interface for this, library
    users must write their own error-detecting/handling routines to parse
    the obscure apitools decoding artifacts.
    
    Given that apitools is the one generating this structure, it makes much
    more sense for this error-detecting logic to be provided by apitools
    directly.
    msuozzo committed Apr 3, 2018
    Copy the full SHA
    615f9c4 View commit details
  2. Merge pull request #207 from msuozzo/master

    Add a function for detecting unrecognized fields.
    kevinli7 authored Apr 3, 2018
    Copy the full SHA
    3abcfe1 View commit details

Commits on Apr 11, 2018

  1. Merge pull request #210 from craigcitro/dedep

    Make apitools work more smoothly in python3
    kevinli7 authored Apr 11, 2018
    Copy the full SHA
    60a08f8 View commit details
  2. Convert generated api client/message docstrings into raw strings.

    In Python 3, illegal escape sequences in strings throw deprecation
    warnings. Since there are no restrictions on the descriptions of the
    docstrings, converting docstrings to raw strings will prevent
    deprecation warnings from being thrown.
    kevinli7 committed Apr 11, 2018
    Copy the full SHA
    75378a7 View commit details

Commits on Apr 17, 2018

  1. Merge pull request #216 from kevinli7/docstring2

    Convert generated api client/message docstrings into raw strings.
    kevinli7 authored Apr 17, 2018
    Copy the full SHA
    21ad21e View commit details
  2. Copy the full SHA
    b963534 View commit details
  3. Merge pull request #218 from kevinli7/lintfix

    Fix lint errors in apitools and pin pycodestyle to version 2.4.0.
    kevinli7 authored Apr 17, 2018
    Copy the full SHA
    d05442c View commit details
Showing with 7,549 additions and 15,567 deletions.
  1. +22 −18 .travis.yml
  2. +1 −0 MANIFEST.in
  3. +10 −3 README.rst
  4. +1 −1 apitools/base/protorpclite/descriptor.py
  5. +37 −37 apitools/base/protorpclite/descriptor_test.py
  6. +3 −3 apitools/base/protorpclite/message_types.py
  7. +9 −7 apitools/base/protorpclite/messages.py
  8. +220 −215 apitools/base/protorpclite/messages_test.py
  9. +38 −7 apitools/base/protorpclite/protojson.py
  10. +76 −49 apitools/base/protorpclite/protojson_test.py
  11. +36 −13 apitools/base/protorpclite/test_util.py
  12. +26 −4 apitools/base/protorpclite/util.py
  13. +26 −18 apitools/base/protorpclite/util_test.py
  14. +0 −373 apitools/base/py/app2.py
  15. +30 −5 apitools/base/py/base_api.py
  16. +45 −7 apitools/base/py/base_api_test.py
  17. +0 −161 apitools/base/py/base_cli.py
  18. +21 −7 apitools/base/py/batch.py
  19. +65 −4 apitools/base/py/batch_test.py
  20. +2 −2 apitools/base/py/buffered_stream_test.py
  21. +0 −35 apitools/base/py/cli.py
  22. +147 −0 apitools/base/py/compression.py
  23. +150 −0 apitools/base/py/compression_test.py
  24. +200 −88 apitools/base/py/credentials_lib.py
  25. +92 −27 apitools/base/py/credentials_lib_test.py
  26. +4 −671 apitools/base/py/encoding.py
  27. +808 −0 apitools/base/py/encoding_helper.py
  28. +243 −49 apitools/base/py/encoding_test.py
  29. +8 −4 apitools/base/py/exceptions.py
  30. +14 −8 apitools/base/py/exceptions_test.py
  31. +10 −4 apitools/base/py/extra_types.py
  32. +2 −3 apitools/base/py/extra_types_test.py
  33. +617 −0 apitools/base/py/gzip.py
  34. +514 −0 apitools/base/py/gzip_test.py
  35. +13 −4 apitools/base/py/http_wrapper.py
  36. +56 −4 apitools/base/py/http_wrapper_test.py
  37. +65 −12 apitools/base/py/list_pager.py
  38. +88 −7 apitools/base/py/list_pager_test.py
  39. +2 −2 apitools/base/py/stream_slice_test.py
  40. +45 −3 apitools/base/py/testing/mock.py
  41. +99 −22 apitools/base/py/testing/mock_test.py
  42. +146 −33 apitools/base/py/transfer.py
  43. +343 −3 apitools/base/py/transfer_test.py
  44. +10 −3 apitools/base/py/util.py
  45. +17 −12 apitools/base/py/util_test.py
  46. +0 −20 apitools/data/__init__.py
  47. +0 −15 apitools/data/apitools_client_secrets.json
  48. +10 −23 apitools/gen/client_generation_test.py
  49. +0 −608 apitools/gen/command_registry.py
  50. +7 −5 apitools/gen/extended_descriptor.py
  51. +25 −26 apitools/gen/gen_client.py
  52. +4 −21 apitools/gen/gen_client_lib.py
  53. +37 −19 apitools/gen/gen_client_test.py
  54. +2 −2 apitools/gen/message_registry.py
  55. +16 −12 apitools/gen/service_registry.py
  56. +3 −6 apitools/gen/test_utils.py
  57. +716 −0 apitools/gen/testdata/dns/dns_2015-08-07-preview.json
  58. +112 −21 apitools/gen/util.py
  59. +63 −3 apitools/gen/util_test.py
  60. +0 −339 apitools/scripts/oauth2l.py
  61. +0 −351 apitools/scripts/oauth2l_test.py
  62. +1 −1 apitools/scripts/testdata/fake_client_secrets.json
  63. +0 −352 default.pylintrc
  64. +1 −1 ez_setup.py
  65. +0 −235 run_pylint.py
  66. +2 −0 samples/bigquery_sample/bigquery_v2/__init__.py
  67. +0 −1,096 samples/bigquery_sample/bigquery_v2/bigquery_v2.py
  68. +205 −200 samples/bigquery_sample/bigquery_v2/bigquery_v2_client.py
  69. +110 −108 samples/bigquery_sample/bigquery_v2/bigquery_v2_messages.py
  70. +2 −0 samples/dns_sample/dns_v1/__init__.py
  71. +0 −554 samples/dns_sample/dns_v1/dns_v1.py
  72. +97 −92 samples/dns_sample/dns_v1/dns_v1_client.py
  73. +34 −32 samples/dns_sample/dns_v1/dns_v1_messages.py
  74. +9 −8 samples/dns_sample/gen_dns_client_test.py
  75. +2 −0 samples/fusiontables_sample/fusiontables_v1/__init__.py
  76. +0 −1,797 samples/fusiontables_sample/fusiontables_v1/fusiontables_v1.py
  77. +292 −287 samples/fusiontables_sample/fusiontables_v1/fusiontables_v1_client.py
  78. +79 −77 samples/fusiontables_sample/fusiontables_v1/fusiontables_v1_messages.py
  79. +10 −9 samples/iam_sample/iam_client_test.py
  80. +6 −0 samples/iam_sample/iam_v1.json
  81. +2 −0 samples/iam_sample/iam_v1/__init__.py
  82. +0 −921 samples/iam_sample/iam_v1/iam_v1.py
  83. +169 −164 samples/iam_sample/iam_v1/iam_v1_client.py
  84. +67 −59 samples/iam_sample/iam_v1/iam_v1_messages.py
  85. +22 −5 samples/regenerate_samples.py
  86. +2 −2 samples/servicemanagement_sample/messages_test.py
  87. +2 −0 samples/servicemanagement_sample/servicemanagement_v1/__init__.py
  88. +0 −1,520 samples/servicemanagement_sample/servicemanagement_v1/servicemanagement_v1.py
  89. +246 −241 samples/servicemanagement_sample/servicemanagement_v1/servicemanagement_v1_client.py
  90. +194 −188 samples/servicemanagement_sample/servicemanagement_v1/servicemanagement_v1_messages.py
  91. +3 −3 samples/storage_sample/downloads_test.py
  92. +2 −1 samples/storage_sample/storage_v1.json
  93. +2 −0 samples/storage_sample/storage_v1/__init__.py
  94. +0 −3,578 samples/storage_sample/storage_v1/storage_v1.py
  95. +421 −416 samples/storage_sample/storage_v1/storage_v1_client.py
  96. +161 −158 samples/storage_sample/storage_v1/storage_v1_messages.py
  97. +4 −4 samples/storage_sample/uploads_test.py
  98. +4 −6 samples/uptodate_check_test.py
  99. +6 −0 setup.cfg
  100. +21 −12 setup.py
  101. +15 −41 tox.ini
40 changes: 22 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
language: python
sudo: false
env:
- TOX_ENV=py27
- TOX_ENV=py27oldoauth2client
- TOX_ENV=py34
- TOX_ENV=py35
- TOX_ENV=lint
matrix:
include:
- python: "2.7"
env: TOX_ENV=lint
- python: "2.7"
env: TOX_ENV=py27-oauth2client1
- python: "2.7"
env: TOX_ENV=py27-oauth2client2
- python: "2.7"
env: TOX_ENV=py27-oauth2client3
- python: "2.7"
env: TOX_ENV=py27-oauth2client4
- python: "3.5"
env: TOX_ENV=py35-oauth2client1
- python: "3.5"
env: TOX_ENV=py35-oauth2client2
- python: "3.5"
env: TOX_ENV=py35-oauth2client3
- python: "3.5"
env: TOX_ENV=py35-oauth2client4
install:
- pip install tox
- pip install . --allow-external argparse
- pip install . argparse
script: tox -e $TOX_ENV
after_success:
- if [[ "${TOX_ENV}" == "py27" ]]; then tox -e coveralls; fi

# Tweak for adding python3.5; see
# https://github.com/travis-ci/travis-ci/issues/4794
addons:
apt:
sources:
- deadsnakes
packages:
- python3.5
- if [[ "${TOX_ENV}" == "py27-oauth2client4" ]]; then tox -e coveralls; fi
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include LICENSE
include *.py
include *.txt
include *.md
13 changes: 10 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**DEPRECATED - Please see alternatives below**

google-apitools
===============

@@ -6,9 +8,14 @@ google-apitools
``google-apitools`` is a collection of utilities to make it easier to build
client-side tools, especially those that talk to Google APIs.

**NOTE**: This library is stable, but in maintenance mode, and not under
active development. However, any bugs or security issues will be fixed
promptly.
**NOTE**: This library is deprecated and unsupported. Please read below for suggested alternatives.

Alternatives to apitools
-----------------------
For the official Cloud client libraries used to communicating with Google Cloud APIs, go to https://cloud.google.com/apis/docs/cloud-client-libraries.

To generate Python API client libraries for APIs specified by protos, such as those inside Google, see https://github.com/googleapis/gapic-generator-python.
API client library generators for other languages can be found in https://github.com/googleapis.

Installing as a library
-----------------------
2 changes: 1 addition & 1 deletion apitools/base/protorpclite/descriptor.py
Original file line number Diff line number Diff line change
@@ -292,7 +292,7 @@ def describe_enum(enum_definition):
enum_descriptor.name = enum_definition.definition_name().split('.')[-1]

values = []
for number in enum_definition.numbers():
for number in sorted(enum_definition.numbers()):
value = enum_definition.lookup_by_number(number)
values.append(describe_enum_value(value))

74 changes: 37 additions & 37 deletions apitools/base/protorpclite/descriptor_test.py
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@
"""Tests for apitools.base.protorpclite.descriptor."""
import platform
import types
import unittest

import six
import unittest2

from apitools.base.protorpclite import descriptor
from apitools.base.protorpclite import message_types
@@ -49,7 +49,7 @@ class MyEnum(messages.Enum):

described = descriptor.describe_enum_value(MyEnum.MY_NAME)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeEnumTest(test_util.TestCase):
@@ -63,7 +63,7 @@ class EmptyEnum(messages.Enum):

described = descriptor.describe_enum(EmptyEnum)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testNestedEnum(self):
class MyScope(messages.Message):
@@ -76,10 +76,10 @@ class NestedEnum(messages.Enum):

described = descriptor.describe_enum(MyScope.NestedEnum)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

@unittest2.skipIf('PyPy' in platform.python_implementation(),
'todo: reenable this')
@unittest.skipIf('PyPy' in platform.python_implementation(),
'todo: reenable this')
def testEnumWithItems(self):
class EnumWithItems(messages.Enum):
A = 3
@@ -105,7 +105,7 @@ class EnumWithItems(messages.Enum):

described = descriptor.describe_enum(EnumWithItems)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeFieldTest(test_util.TestCase):
@@ -127,7 +127,7 @@ def testLabel(self):

described = descriptor.describe_field(field)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testDefault(self):
test_cases = (
@@ -154,7 +154,7 @@ def testDefault(self):

described = descriptor.describe_field(field)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testDefault_EnumField(self):
class MyEnum(messages.Enum):
@@ -174,7 +174,7 @@ class MyEnum(messages.Enum):
expected.default_value = '1'

described = descriptor.describe_field(field)
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testMessageField(self):
field = messages.MessageField(descriptor.FieldDescriptor, 10)
@@ -190,7 +190,7 @@ def testMessageField(self):

described = descriptor.describe_field(field)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testDateTimeField(self):
field = message_types.DateTimeField(20)
@@ -206,7 +206,7 @@ def testDateTimeField(self):

described = descriptor.describe_field(field)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeMessageTest(test_util.TestCase):
@@ -220,7 +220,7 @@ class MyMessage(messages.Message):

described = descriptor.describe_message(MyMessage)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testDefinitionWithFields(self):
class MessageWithFields(messages.Message):
@@ -242,7 +242,7 @@ class MessageWithFields(messages.Message):

described = descriptor.describe_message(MessageWithFields)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testNestedEnum(self):
class MessageWithEnum(messages.Message):
@@ -265,7 +265,7 @@ class Music(messages.Enum):

described = descriptor.describe_message(MessageWithEnum)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testNestedMessage(self):
class MessageWithMessage(messages.Message):
@@ -281,7 +281,7 @@ class Nesty(messages.Message):

described = descriptor.describe_message(MessageWithMessage)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeFileTest(test_util.TestCase):
@@ -309,7 +309,7 @@ def testEmptyModule(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testNoPackageName(self):
"""Test describing a module with no module name."""
@@ -319,7 +319,7 @@ def testNoPackageName(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testPackageName(self):
"""Test using the 'package' module attribute."""
@@ -331,7 +331,7 @@ def testPackageName(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testMain(self):
"""Test using the 'package' module attribute."""
@@ -343,7 +343,7 @@ def testMain(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testMessages(self):
"""Test that messages are described."""
@@ -363,7 +363,7 @@ def testMessages(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)

def testEnums(self):
"""Test that enums are described."""
@@ -383,7 +383,7 @@ def testEnums(self):

described = descriptor.describe_file(module)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeFileSetTest(test_util.TestCase):
@@ -394,7 +394,7 @@ def testNoModules(self):
described = descriptor.describe_file_set([])
described.check_initialized()
# The described FileSet.files will be None.
self.assertEquals(descriptor.FileSet(), described)
self.assertEqual(descriptor.FileSet(), described)

def testWithModules(self):
"""Test what happens when no modules provided."""
@@ -410,32 +410,32 @@ def testWithModules(self):

described = descriptor.describe_file_set(modules)
described.check_initialized()
self.assertEquals(expected, described)
self.assertEqual(expected, described)


class DescribeTest(test_util.TestCase):

def testModule(self):
self.assertEquals(descriptor.describe_file(test_util),
self.assertEqual(descriptor.describe_file(test_util),
descriptor.describe(test_util))

def testField(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_field(test_util.NestedMessage.a_value),
descriptor.describe(test_util.NestedMessage.a_value))

def testEnumValue(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_enum_value(
test_util.OptionalMessage.SimpleEnum.VAL1),
descriptor.describe(test_util.OptionalMessage.SimpleEnum.VAL1))

def testMessage(self):
self.assertEquals(descriptor.describe_message(test_util.NestedMessage),
self.assertEqual(descriptor.describe_message(test_util.NestedMessage),
descriptor.describe(test_util.NestedMessage))

def testEnum(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_enum(test_util.OptionalMessage.SimpleEnum),
descriptor.describe(test_util.OptionalMessage.SimpleEnum))

@@ -451,25 +451,25 @@ def fn(self):
'string',
1.2,
None):
self.assertEquals(None, descriptor.describe(value))
self.assertEqual(None, descriptor.describe(value))


class ModuleFinderTest(test_util.TestCase):

def testFindMessage(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_message(descriptor.FileSet),
descriptor.import_descriptor_loader(
'apitools.base.protorpclite.descriptor.FileSet'))

def testFindField(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_field(descriptor.FileSet.files),
descriptor.import_descriptor_loader(
'apitools.base.protorpclite.descriptor.FileSet.files'))

def testFindEnumValue(self):
self.assertEquals(
self.assertEqual(
descriptor.describe_enum_value(
test_util.OptionalMessage.SimpleEnum.VAL1),
descriptor.import_descriptor_loader(
@@ -489,8 +489,8 @@ def setUp(self):
})

def testLookupPackage(self):
self.assertEquals('csv', self.library.lookup_package('csv'))
self.assertEquals(
self.assertEqual('csv', self.library.lookup_package('csv'))
self.assertEqual(
'apitools.base.protorpclite',
self.library.lookup_package('apitools.base.protorpclite'))

@@ -508,8 +508,8 @@ def testNoPackage(self):
'Could not find definition for not.real',
self.library.lookup_package, 'not.real.Packageless')

self.assertEquals(None, self.library.lookup_package('Packageless'))
self.assertEqual(None, self.library.lookup_package('Packageless'))


if __name__ == '__main__':
unittest2.main()
unittest.main()
6 changes: 3 additions & 3 deletions apitools/base/protorpclite/message_types.py
Original file line number Diff line number Diff line change
@@ -78,8 +78,8 @@ def value_from_message(self, message):
"""
message = super(DateTimeField, self).value_from_message(message)
if message.time_zone_offset is None:
return datetime.datetime.utcfromtimestamp(
message.milliseconds / 1000.0)
return datetime.datetime.fromtimestamp(
message.milliseconds / 1000.0, tz=datetime.timezone.utc).replace(tzinfo=None)

# Need to subtract the time zone offset, because when we call
# datetime.fromtimestamp, it will add the time zone offset to the
@@ -97,7 +97,7 @@ def value_to_message(self, value):
# DateTimeMessage's milliseconds field.
if value.tzinfo is None:
time_zone_offset = 0
local_epoch = datetime.datetime.utcfromtimestamp(0)
local_epoch = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc).replace(tzinfo=None)
else:
time_zone_offset = util.total_seconds(
value.tzinfo.utcoffset(value))
Loading