| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 """Tests for ../{tested_file}.py""" |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Tool-specific testable functions for antibody.""" | |
| 6 | 2 |
| 7 import argparse | 3 import argparse |
| 8 import unittest | 4 import unittest |
| 9 | 5 |
| 10 from infra.tools.antibody import antibody | 6 from infra.tools.{toolname} import {tested_file} |
| 11 | 7 |
| 12 | 8 |
| 13 class MyTest(unittest.TestCase): | 9 class MyTest(unittest.TestCase): |
| 14 def test_arguments(self): | 10 def test_arguments(self): |
| 15 parser = argparse.ArgumentParser() | 11 parser = argparse.ArgumentParser() |
| 16 antibody.add_argparse_options(parser) | 12 {tested_file}.add_argparse_options(parser) |
| 17 args = parser.parse_args(['--my-argument', 'value']) | 13 args = parser.parse_args(['--my-argument', 'value']) |
| 18 self.assertEqual(args.my_argument, 'value') | 14 self.assertEqual(args.my_argument, 'value') |
| 19 | 15 |
| 20 ## expect_tests style: the test method returns a value (expectation) | 16 ## expect_tests style: the test method returns a value (expectation) |
| 21 ## that is stored when run in 'train' mode, and compared to in 'test' mode. | 17 ## that is stored when run in 'train' mode, and compared to in 'test' mode. |
| 22 ## If the stored and returned values do not match, the test fails. | 18 ## If the stored and returned values do not match, the test fails. |
| 19 ## Use sparingly, asserts are usually better. |
| 23 ## | 20 ## |
| 24 ## def test_my_first_test_with_expectation(self): | 21 ## def test_my_first_test_with_expectation(self): |
| 25 ## # Use hash() here to make sure the test fails in any case. | 22 ## parser = argparse.ArgumentParser() |
| 26 ## return hash(MyTest) | 23 ## {tested_file}.add_argparse_options(parser) |
| 24 ## args = parser.parse_args(['--my-argument', 'value']) |
| 25 ## return {{'my_argument': args.my_argument}} |
| OLD | NEW |