Be explicit about why we use ‘io.BytesIO’ for the fake file.
[python-gajja.git] / test / test_tutorial.py
blobd1f4f8a17f36d262b108ef2a67a45eb4064ef641
1 # -*- coding: utf-8; -*-
3 # test/test_tutorial.py
4 # Part of Gajja, a Python test double library.
6 # Copyright © 2016 Ben Finney <ben+python@benfinney.id.au>
8 # This is free software: you may copy, modify, and/or distribute this work
9 # under the terms of the GNU General Public License as published by the
10 # Free Software Foundation; version 3 of that license or any later version.
11 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
13 """ Test suite for tutorial examples. """
15 from __future__ import (absolute_import, unicode_literals)
17 import os
18 import os.path
19 import doctest
21 __package__ = str("test")
22 __import__(__package__)
24 this_dir = os.path.dirname(__file__)
25 doc_dir = os.path.join(os.path.pardir, "doc")
28 def load_tests(loader, tests, pattern):
29 """ Test discovery hook to load test cases for this module.
31 :param loader: The `unittest.TestLoader` instance to use for
32 loading test cases.
33 :param tests: Collection of cases already loaded for this
34 module.
35 :param pattern: File glob pattern to match test modules.
36 :return: A `unittest.TestSuite` instance comprising the
37 modified test suite for this module.
39 See the `load_tests protocol`_ section of the Python
40 `unittest` documentation.
42 .. _load_tests protocol:
43 https://docs.python.org/3/library/unittest.html#load-tests-protocol
45 """
46 tutorial_file_path = os.path.join(doc_dir, "tutorial.txt")
47 tests.addTests(doctest.DocFileSuite(
48 tutorial_file_path,
49 optionflags=doctest.NORMALIZE_WHITESPACE))
51 return tests
54 # Local variables:
55 # coding: utf-8
56 # mode: python
57 # End:
58 # vim: fileencoding=utf-8 filetype=python :