main
Last change
on this file was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
720 bytes
|
Line | |
---|
1 | from pymysql.optionfile import Parser |
---|
2 | from unittest import TestCase |
---|
3 | from pymysql._compat import PY2 |
---|
4 | |
---|
5 | try: |
---|
6 | from cStringIO import StringIO |
---|
7 | except ImportError: |
---|
8 | from io import StringIO |
---|
9 | |
---|
10 | |
---|
11 | __all__ = ['TestParser'] |
---|
12 | |
---|
13 | |
---|
14 | _cfg_file = (r""" |
---|
15 | [default] |
---|
16 | string = foo |
---|
17 | quoted = "bar" |
---|
18 | single_quoted = 'foobar' |
---|
19 | """) |
---|
20 | |
---|
21 | |
---|
22 | class TestParser(TestCase): |
---|
23 | |
---|
24 | def test_string(self): |
---|
25 | parser = Parser() |
---|
26 | if PY2: |
---|
27 | parser.readfp(StringIO(_cfg_file)) |
---|
28 | else: |
---|
29 | parser.read_file(StringIO(_cfg_file)) |
---|
30 | self.assertEqual(parser.get("default", "string"), "foo") |
---|
31 | self.assertEqual(parser.get("default", "quoted"), "bar") |
---|
32 | self.assertEqual(parser.get("default", "single_quoted"), "foobar") |
---|
Note: See
TracBrowser
for help on using the repository browser.