~ubuntu-branches/ubuntu/vivid/lazr.restfulclient/vivid-proposed

« back to all changes in this revision

Viewing changes to src/lazr/authentication/tests/test_docs.py

  • Committer: Package Import Robot
  • Author(s): Dimitri John Ledkov
  • Date: 2014-12-06 01:04:46 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20141206010446-axq9v8zp6kkfts8v
Tags: 0.13.4-0ubuntu1
Upload to vivid, because my subkey is not getting accepted by
ftp-master.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2009 Canonical Ltd.  All rights reserved.
 
2
#
 
3
# This file is part of lazr.authentication
 
4
#
 
5
# lazr.authentication is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU Lesser General Public License as published by
 
7
# the Free Software Foundation, version 3 of the License.
 
8
#
 
9
# lazr.authentication is distributed in the hope that it will be useful, but WITHOUT
 
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
12
# License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with lazr.authentication.  If not, see <http://www.gnu.org/licenses/>.
 
16
"Test harness for doctests."
 
17
 
 
18
# pylint: disable-msg=E0611,W0142
 
19
 
 
20
__metaclass__ = type
 
21
__all__ = [
 
22
    'additional_tests',
 
23
    ]
 
24
 
 
25
import atexit
 
26
import doctest
 
27
import os
 
28
# pylint: disable-msg=F0401
 
29
from pkg_resources import (
 
30
    resource_filename, resource_exists, resource_listdir, cleanup_resources)
 
31
import unittest
 
32
 
 
33
DOCTEST_FLAGS = (
 
34
    doctest.ELLIPSIS |
 
35
    doctest.NORMALIZE_WHITESPACE |
 
36
    doctest.REPORT_NDIFF)
 
37
 
 
38
 
 
39
def additional_tests():
 
40
    "Run the doc tests (README.txt and docs/*, if any exist)"
 
41
    doctest_files = [
 
42
        os.path.abspath(resource_filename('lazr.authentication', 'README.txt'))]
 
43
    if resource_exists('lazr.authentication', 'docs'):
 
44
        for name in resource_listdir('lazr.authentication', 'docs'):
 
45
            if name.endswith('.txt'):
 
46
                doctest_files.append(
 
47
                    os.path.abspath(
 
48
                        resource_filename('lazr.authentication', 'docs/%s' % name)))
 
49
    kwargs = dict(module_relative=False, optionflags=DOCTEST_FLAGS)
 
50
    atexit.register(cleanup_resources)
 
51
    return unittest.TestSuite((
 
52
        doctest.DocFileSuite(*doctest_files, **kwargs)))