Commit ae2d0a61 authored by Matt Glazar's avatar Matt Glazar Committed by Facebook Github Bot

Fix tests with Python 2.7

Summary:
Some people want to use getdeps with Python 2.7. This looks easy to do, so take a step toward Python 2.7 support by fixing getdeps' tests when run with Python 2.7.

For Python 3, this diff should not change behavior.

This diff should address https://github.com/facebook/bistro/issues/35.

Reviewed By: snarkmaster

Differential Revision: D16435667

fbshipit-source-id: f5c262b12995b609263341c4de26dac7f9b12b70
parent e730c5f7
......@@ -165,8 +165,9 @@ class ManifestParser(object):
if fp is None:
with open(file_name, "r") as fp:
config.readfp(fp)
elif isinstance(fp, str):
# For testing purposes, parse from a string
elif isinstance(fp, type("")):
# For testing purposes, parse from a string (str
# or unicode)
config.readfp(io.StringIO(fp))
else:
config.readfp(fp)
......
......@@ -8,6 +8,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
import unittest
import pkg_resources
......@@ -211,3 +212,8 @@ foo = bar
patch_loader(__name__)
manifests = load_all_manifests(None)
self.assertNotEqual(0, len(manifests), msg="parsed some number of manifests")
if sys.version_info < (3, 2):
def assertRaisesRegex(self, *args, **kwargs):
return self.assertRaisesRegexp(*args, **kwargs)
......@@ -6,7 +6,7 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import absolute_import, division, print_function
import unittest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment