1#!/usr/bin/python3.8
2#
3# Copyright 2008 Google Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Base test code for Graphy."""
18
19import unittest
20
21
22class GraphyTest(unittest.TestCase):
23  """Base class for other Graphy tests."""
24
25  def assertIn(self, a, b, msg=None):
26    """Just like self.assert_(a in b), but with a nicer default message."""
27    if msg is None:
28      msg = '"%s" not found in "%s"' % (a, b)
29    self.assert_(a in b, msg)
30
31  def assertNotIn(self, a, b, msg=None):
32    """Just like self.assert_(a not in b), but with a nicer default message."""
33    if msg is None:
34      msg = '"%s" unexpectedly found in "%s"' % (a, b)
35    self.assert_(a not in b, msg)
36
37  def Param(self, param_name, chart=None):
38    """Helper to look up a Google Chart API parameter for the given chart."""
39    if chart is None:
40      chart = self.chart
41    params = chart.display._Params(chart)
42    return params[param_name]
43
44def main():
45  """Wrap unittest.main (for convenience of caller)."""
46  return unittest.main()
47