Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: recipe_engine/unittests/recipe_test_api_test.py

Issue 2707593002: Whitelist allowed test names
Patch Set: Use correct regex Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/recipe_test_api.py ('k') | unittests/errors_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/unittests/recipe_test_api_test.py
diff --git a/recipe_engine/unittests/recipe_test_api_test.py b/recipe_engine/unittests/recipe_test_api_test.py
index 9f0d29eba55959989729269bc7a9642d239fddf9..31515da3a3d969d6349ad278b853987e2abc83d7 100755
--- a/recipe_engine/unittests/recipe_test_api_test.py
+++ b/recipe_engine/unittests/recipe_test_api_test.py
@@ -15,7 +15,7 @@ class EXC(Exception):
class TestExpectedException(unittest.TestCase):
def testRecognizeException(self):
"""An expected exception is correctly recognized."""
- test_data = recipe_test_api.TestData()
+ test_data = recipe_test_api.TestData("test")
test_data.expect_exception(EXC.__name__)
self.assertFalse(test_data.consumed)
@@ -29,7 +29,7 @@ class TestExpectedException(unittest.TestCase):
def testNewException(self):
"""An unexpected exception results in being told to re-raise ."""
- test_data = recipe_test_api.TestData()
+ test_data = recipe_test_api.TestData("test")
self.assertTrue(test_data.consumed)
with test_data.should_raise_exception(EXC()) as should_raise:
@@ -39,10 +39,18 @@ class TestExpectedException(unittest.TestCase):
def testDisabledTestData(self):
"""Disabled test data correctly re-raises all exceptions."""
- test_data = recipe_test_api.TestData()
+ test_data = recipe_test_api.TestData("test")
with test_data.should_raise_exception(EXC()) as should_raise:
self.assertTrue(should_raise)
+ def test_invalid_test_names(self):
+ for bad in ('bad name', 'a\////', 'b\\\\', 'c(*#&($'):
+ self.assertFalse(recipe_test_api.is_valid_test_name(bad))
+
+ def test_valid_test_names(self):
+ for good in ('good', 'with_underscores_now', 'and_numbers_1'):
+ self.assertTrue(recipe_test_api.is_valid_test_name(good))
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « recipe_engine/recipe_test_api.py ('k') | unittests/errors_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698