コード例 #1
0
ファイル: test_test.py プロジェクト: jettisonjoe/openhtf
    def test_bad_mock_plug_args(self):
        # Stub test* method that one might wrap with test.patch_plugs().
        def stub_test_method(self, plug_one, plug_two):
            pass

        # Test that we catch weird extra test method args.
        with self.assertRaises(test.InvalidTestError):
            test.patch_plugs(plug_one="unused")(stub_test_method)

        # Test that we catch mocks that aren't expected.
        with self.assertRaises(test.InvalidTestError):
            test.patch_plugs(plug_one="unused", plug_two="unused", plug_three="unused")(stub_test_method)

        # Test that we catch weird plug specifications.
        with self.assertRaises(ValueError):
            test.patch_plugs(plug_one="bad_spec_no_dots", plug_two="unused")(stub_test_method)
        with self.assertRaises(KeyError):
            test.patch_plugs(plug_one="bad.spec.invalid.module", plug_two="also.bad")(stub_test_method)
コード例 #2
0
ファイル: test_test.py プロジェクト: zamora18/openhtf
  def test_bad_mock_plug_args(self):
    # Stub test* method that one might wrap with test.patch_plugs().
    def stub_test_method(self, plug_one, plug_two):
      pass

    # Test that we catch weird extra test method args.
    with self.assertRaises(test.InvalidTestError):
      test.patch_plugs(plug_one='unused')(stub_test_method)

    # Test that we catch mocks that aren't expected.
    with self.assertRaises(test.InvalidTestError):
      test.patch_plugs(plug_one='unused', plug_two='unused',
                       plug_three='unused')(stub_test_method)

    # Test that we catch weird plug specifications.
    with self.assertRaises(ValueError):
      test.patch_plugs(plug_one='bad_spec_no_dots',
                       plug_two='unused')(stub_test_method)
    with self.assertRaises(KeyError):
      test.patch_plugs(plug_one='bad.spec.invalid.module',
                       plug_two='also.bad')(stub_test_method)