File: test_base.py

package info (click to toggle)
pygooglechart 0.4.0%2Bgit20140622-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 364 kB
  • ctags: 300
  • sloc: python: 1,501; makefile: 130; sh: 5
file content (47 lines) | stat: -rw-r--r-- 996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import sys
import os
import warnings

try:
	import urllib.request, urllib.parse, urllib.error
except ImportError:
	import urllib2

ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, ROOT)

import pygooglechart as gc


class TestBase(unittest.TestCase):

    def setUp(self):

        # All tests require warnings to be raised
        self.raise_warnings(True)

        self.temp_image = 'temp.png'

    def tearDown(self):
        if os.path.exists(self.temp_image):
            os.unlink(self.temp_image)

    def raise_warnings(self, rw):
        gc._reset_warnings()

        if rw:
            warnings.simplefilter('error')
        else:
            # Don't print out warnings if we're expecting them--so we can have
            # nicer looking tests! :)
            warnings.simplefilter('ignore')

    def assertChartURL(self, url, query):
        self.assertTrue(url.endswith(query))