@@ -115,5 +115,40 @@ def testInitPyFilesNotCreatedWhenLegacyCreateInitIsSet(self):
115115 os .path .exists ('bazel-bin/src/a/a.runfiles/__main__/src/a/__init__.py' ))
116116
117117
118+ class TestPy3 (test_base .TestBase ):
119+
120+ def createSimpleFiles (self ):
121+ self .ScratchFile ('WORKSPACE' )
122+
123+ self .ScratchFile ('BUILD' , [
124+ 'py_library(name="a", srcs=["a.py"], srcs_version = "PY3")' ,
125+ 'py_binary(name="b", srcs=["b.py"], deps=[":a"], srcs_version="PY3", default_python_version="PY3")' ,
126+ 'py_test(name="t", srcs=["t.py"], deps=[":a"], srcs_version="PY3", default_python_version="PY3")' ,
127+ ])
128+
129+ self .ScratchFile ('a.py' , [
130+ 'import sys' ,
131+ 'if sys.version_info[0] < 3:' ,
132+ ' raise Exception("Not python 3")'
133+ ])
134+
135+ self .ScratchFile ('b.py' , [
136+ 'import a' ,
137+ ])
138+
139+ self .ScratchFile ('t.py' , [
140+ 'import a' ,
141+ ])
142+
143+ def testPyBinary (self ):
144+ self .createSimpleFiles ()
145+ exit_code , _ , stderr = self .RunBazel (['run' , '//:b' ])
146+ self .AssertExitCode (exit_code , 0 , stderr )
147+
148+ def testPyTest (self ):
149+ self .createSimpleFiles ()
150+ exit_code , _ , stderr = self .RunBazel (['test' , '//:t' ])
151+ self .AssertExitCode (exit_code , 0 , stderr )
152+
118153if __name__ == '__main__' :
119154 unittest .main ()
0 commit comments