File: test_rst.py

package info (click to toggle)
pyephem 4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,380 kB
  • sloc: ansic: 77,574; python: 2,529; makefile: 74
file content (43 lines) | stat: -rwxr-xr-x 1,113 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python

import datetime
import doctest
import unittest
import os.path
import sys
import time
from glob import glob

class FakeDatetime(datetime.datetime):
    @classmethod
    def utcnow(cls):
        return cls(2015, 12, 14, 15, 42, 14)

FakeDatetime.__name__ = 'datetime.datetime'

def load_tests(loader, tests, pattern):

    # Since tzset does not work under Windows, just give up.
    if os.name == 'nt':
        return unittest.TestSuite(tests)

    # Force time zone to EST/EDT to make localtime tests work.
    os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
    time.tzset()

    # The different floating-point formatting rules in 2.6 and prior
    # ruin our doctests.

    tests = []

    datetime.datetime = FakeDatetime

    if sys.version_info >= (3, 9):
        tests.extend([
            doctest.DocFileSuite('../doc/%s' % os.path.basename(path))
            for path in glob(os.path.dirname(__file__) + '/../doc/*.rst')
            if os.path.split(path)[-1] != 'index.rst'
            # skips time-dependent doctest in index.rst
            ])

    return unittest.TestSuite(tests)