bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k
59
by gak
- Reorganised tests |
1 |
#!/usr/bin/env python
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
||
4 |
import unittest |
|
5 |
import sys |
|
6 |
import os |
|
7 |
import warnings |
|
8 |
import urllib |
|
9 |
||
10 |
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |
|
11 |
sys.path.insert(0, ROOT) |
|
12 |
||
13 |
import pygooglechart as gc |
|
14 |
||
15 |
||
16 |
class TestBase(unittest.TestCase): |
|
17 |
||
18 |
def setUp(self): |
|
19 |
||
20 |
# All tests require warnings to be raised
|
|
21 |
self.raise_warnings(True) |
|
22 |
||
23 |
self.temp_image = 'temp.png' |
|
24 |
||
25 |
def tearDown(self): |
|
26 |
if os.path.exists(self.temp_image): |
|
27 |
os.unlink(self.temp_image) |
|
28 |
||
29 |
def raise_warnings(self, rw): |
|
30 |
gc._reset_warnings() |
|
31 |
||
32 |
if rw: |
|
33 |
warnings.simplefilter('error') |
|
34 |
else: |
|
35 |
# Don't print out warnings if we're expecting them--so we can have
|
|
36 |
# nicer looking tests! :)
|
|
37 |
warnings.simplefilter('ignore') |
|
38 |
||
39 |
def assertChartURL(self, url, query): |
|
40 |
self.assertTrue(url.endswith(query)) |
|
41 |
||
42 |
||
43 |