Skip to content

Commit

Permalink
Python3 integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane committed Mar 9, 2018
1 parent d3e102c commit 5a6feef
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/py/bazel/py_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,40 @@ def testInitPyFilesNotCreatedWhenLegacyCreateInitIsSet(self):
os.path.exists('bazel-bin/src/a/a.runfiles/__main__/src/a/__init__.py'))


class TestPy3(test_base.TestBase):

def createSimpleFiles(self):
self.ScratchFile('WORKSPACE')

self.ScratchFile('BUILD', [
'py_library(name="a", srcs=["a.py"], srcs_version = "PY3")',
'py_binary(name="b", srcs=["b.py"], deps=[":a"], srcs_version="PY3", default_python_version="PY3")',
'py_test(name="t", srcs=["t.py"], deps=[":a"], srcs_version="PY3", default_python_version="PY3")',
])

self.ScratchFile('a.py', [
'import sys',
'if sys.version_info[0] < 3:',
' raise Exception("Not python 3")'
])

self.ScratchFile('b.py', [
'import a',
])

self.ScratchFile('t.py', [
'import a',
])

def testPyBinary(self):
self.createSimpleFiles()
exit_code, _, stderr = self.RunBazel(['run', '//:b'])
self.AssertExitCode(exit_code, 0, stderr)

def testPyTest(self):
self.createSimpleFiles()
exit_code, _, stderr = self.RunBazel(['test', '//:t'])
self.AssertExitCode(exit_code, 0, stderr)

if __name__ == '__main__':
unittest.main()

0 comments on commit 5a6feef

Please sign in to comment.