Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
d404af0d
Commit
d404af0d
authored
Jan 19, 2016
by
Thomas Amland
Browse files
add python 3 support to tests
parent
13206d6f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
18 additions
and
14 deletions
+18
-14
googletest/test/gtest_env_var_test.py
googletest/test/gtest_env_var_test.py
+2
-2
googletest/test/gtest_filter_unittest.py
googletest/test/gtest_filter_unittest.py
+8
-5
googletest/test/gtest_output_test.py
googletest/test/gtest_output_test.py
+1
-1
googletest/test/gtest_test_utils.py
googletest/test/gtest_test_utils.py
+1
-1
googletest/test/gtest_throw_on_failure_test.py
googletest/test/gtest_throw_on_failure_test.py
+1
-1
googletest/test/gtest_uninitialized_test.py
googletest/test/gtest_uninitialized_test.py
+2
-2
googletest/test/gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+2
-1
googletest/test/gtest_xml_test_utils.py
googletest/test/gtest_xml_test_utils.py
+1
-1
No files found.
googletest/test/gtest_env_var_test.py
View file @
d404af0d
...
...
@@ -47,8 +47,8 @@ environ = os.environ.copy()
def
AssertEq
(
expected
,
actual
):
if
expected
!=
actual
:
print
'Expected: %s'
%
(
expected
,)
print
' Actual: %s'
%
(
actual
,)
print
(
'Expected: %s'
%
(
expected
,)
)
print
(
' Actual: %s'
%
(
actual
,)
)
raise
AssertionError
...
...
googletest/test/gtest_filter_unittest.py
View file @
d404af0d
...
...
@@ -44,7 +44,10 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import
os
import
re
import
sets
try
:
from
sets
import
Set
as
set
# For Python 2.3 compatibility
except
ImportError
:
pass
import
sys
import
gtest_test_utils
...
...
@@ -58,7 +61,7 @@ import gtest_test_utils
# exception is thrown if the input is anything other than 'True' nor 'False'.
os
.
environ
[
'EMPTY_VAR'
]
=
''
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
EMPTY_VAR
\'
in os.environ'
])
[
sys
.
executable
,
'-c'
,
'import os; print
(
\'
EMPTY_VAR
\'
in os.environ
)
'
])
CAN_PASS_EMPTY_ENV
=
eval
(
child
.
output
)
...
...
@@ -71,7 +74,7 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
os
.
environ
[
'UNSET_VAR'
]
=
'X'
del
os
.
environ
[
'UNSET_VAR'
]
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
UNSET_VAR
\'
not in os.environ'
])
[
sys
.
executable
,
'-c'
,
'import os; print
(
\'
UNSET_VAR
\'
not in os.environ
)
'
])
CAN_UNSET_ENV
=
eval
(
child
.
output
)
...
...
@@ -243,14 +246,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
for
slice_var
in
list_of_sets
:
full_partition
.
extend
(
slice_var
)
self
.
assertEqual
(
len
(
set_var
),
len
(
full_partition
))
self
.
assertEqual
(
set
s
.
Set
(
set_var
),
set
s
.
Set
(
full_partition
))
self
.
assertEqual
(
set
(
set_var
),
set
(
full_partition
))
def
AdjustForParameterizedTests
(
self
,
tests_to_run
):
"""Adjust tests_to_run in case value parameterized tests are disabled."""
global
param_tests_present
if
not
param_tests_present
:
return
list
(
set
s
.
Set
(
tests_to_run
)
-
set
s
.
Set
(
PARAM_TESTS
))
return
list
(
set
(
tests_to_run
)
-
set
(
PARAM_TESTS
))
else
:
return
tests_to_run
...
...
googletest/test/gtest_output_test.py
View file @
d404af0d
...
...
@@ -279,7 +279,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
def
testOutput
(
self
):
output
=
GetOutputOfAllCommands
()
golden_file
=
open
(
GOLDEN_PATH
,
'r
b
'
)
golden_file
=
open
(
GOLDEN_PATH
,
'r'
)
# A mis-configured source control system can cause \r appear in EOL
# sequences when we read the golden file irrespective of an operating
# system used. Therefore, we need to strip those \r's from newlines
...
...
googletest/test/gtest_test_utils.py
View file @
d404af0d
...
...
@@ -178,7 +178,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
'Unable to find the test binary "%s". Please make sure to provide
\n
'
'a path to the binary via the --build_dir flag or the BUILD_DIR
\n
'
'environment variable.'
%
path
)
print
>>
sys
.
stderr
,
message
sys
.
stdout
.
write
(
message
)
sys
.
exit
(
1
)
return
path
...
...
googletest/test/gtest_throw_on_failure_test.py
View file @
d404af0d
...
...
@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
def
Run
(
command
):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
print
'Running "%s". . .'
%
' '
.
join
(
command
)
print
(
'Running "%s". . .'
%
' '
.
join
(
command
)
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
return
p
.
exited
and
p
.
exit_code
==
0
...
...
googletest/test/gtest_uninitialized_test.py
View file @
d404af0d
...
...
@@ -46,8 +46,8 @@ def Assert(condition):
def
AssertEq
(
expected
,
actual
):
if
expected
!=
actual
:
print
'Expected: %s'
%
(
expected
,)
print
' Actual: %s'
%
(
actual
,)
print
(
'Expected: %s'
%
(
expected
,)
)
print
(
' Actual: %s'
%
(
actual
,)
)
raise
AssertionError
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
d404af0d
...
...
@@ -209,7 +209,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'gtest_no_test_unittest'
)
try
:
os
.
remove
(
output_file
)
except
OSError
,
e
:
except
OSError
:
e
=
sys
.
exc_info
()[
1
]
if
e
.
errno
!=
errno
.
ENOENT
:
raise
...
...
googletest/test/gtest_xml_test_utils.py
View file @
d404af0d
...
...
@@ -101,7 +101,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self
.
assertEquals
(
len
(
expected_children
),
len
(
actual_children
),
'number of child elements differ in element '
+
actual_node
.
tagName
)
for
child_id
,
child
in
expected_children
.
iter
items
():
for
child_id
,
child
in
expected_children
.
items
():
self
.
assert_
(
child_id
in
actual_children
,
'<%s> is not in <%s> (in element %s)'
%
(
child_id
,
actual_children
,
actual_node
.
tagName
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment