Exemplo n.º 1
0
    def test_get_matplotlib_version(self):
        """
        Tests for the get_matplotlib_version() function as it continues to
        cause problems.
        """
        original_version = matplotlib.__version__

        matplotlib.__version__ = "1.2.3"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 2, 3])
        matplotlib.__version__ = "0.9.11"
        version = get_matplotlib_version()
        self.assertEqual(version, [0, 9, 11])

        matplotlib.__version__ = "0.9.svn"
        version = get_matplotlib_version()
        self.assertEqual(version, [0, 9, 0])

        matplotlib.__version__ = "1.1.1~rc1-1"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 1, 1])

        matplotlib.__version__ = "1.2.x"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 2, 0])

        matplotlib.__version__ = "1.3.1rc2"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 3, 1])

        # Set it to the original version str just in case.
        matplotlib.__version__ = original_version
Exemplo n.º 2
0
    def test_get_matplotlib_version(self):
        """
        Tests for the get_matplotlib_version() function as it continues to
        cause problems.
        """
        original_version = matplotlib.__version__

        matplotlib.__version__ = "1.2.3"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 2, 3])
        matplotlib.__version__ = "0.9.11"
        version = get_matplotlib_version()
        self.assertEqual(version, [0, 9, 11])

        matplotlib.__version__ = "0.9.svn"
        version = get_matplotlib_version()
        self.assertEqual(version, [0, 9, 0])

        matplotlib.__version__ = "1.1.1~rc1-1"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 1, 1])

        matplotlib.__version__ = "1.2.x"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 2, 0])

        matplotlib.__version__ = "1.3.1rc2"
        version = get_matplotlib_version()
        self.assertEqual(version, [1, 3, 1])

        # Set it to the original version str just in case.
        matplotlib.__version__ = original_version
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     # the root class of AutoDateFormatter (TickHelper) is an old style
     # class prior to matplotlib version 1.2
     if get_matplotlib_version() < [1, 2, 0]:
         AutoDateFormatter.__init__(self, *args, **kwargs)
     else:
         super(ObsPyAutoDateFormatter, self).__init__(*args, **kwargs)
     self.scaled[1. / 24.] = FuncFormatter(format_hour_minute)
     self.scaled[1. / (24. * 60.)] = \
         FuncFormatter(format_hour_minute_second)
     self.scaled[_seconds_to_days(10)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(1))
     # for some reason matplotlib is not using the following intermediate
     # decimal levels (probably some precision issue..) and falls back to
     # the lowest level immediately.
     self.scaled[_seconds_to_days(2e-1)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(2))
     self.scaled[_seconds_to_days(2e-2)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(3))
     self.scaled[_seconds_to_days(2e-3)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(4))
     self.scaled[_seconds_to_days(2e-4)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(5))
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     # the root class of AutoDateFormatter (TickHelper) is an old style
     # class prior to matplotlib version 1.2
     if get_matplotlib_version() < [1, 2, 0]:
         AutoDateFormatter.__init__(self, *args, **kwargs)
     else:
         super(ObsPyAutoDateFormatter, self).__init__(*args, **kwargs)
     self.scaled[1. / 24.] = FuncFormatter(format_hour_minute)
     self.scaled[1. / (24. * 60.)] = \
         FuncFormatter(format_hour_minute_second)
     self.scaled[_seconds_to_days(10)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(1))
     # for some reason matplotlib is not using the following intermediate
     # decimal levels (probably some precision issue..) and falls back to
     # the lowest level immediately.
     self.scaled[_seconds_to_days(2e-1)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(2))
     self.scaled[_seconds_to_days(2e-2)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(3))
     self.scaled[_seconds_to_days(2e-3)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(4))
     self.scaled[_seconds_to_days(2e-4)] = \
         FuncFormatter(decimal_seconds_format_x_decimals(5))
Exemplo n.º 5
0
import inspect
import io
import os
import re
import shutil
import unittest
import warnings

from lxml import etree
import numpy as np

from obspy.core.util.base import NamedTemporaryFile, get_matplotlib_version
from obspy.core.util.misc import CatchOutput, get_untracked_files_from_git, \
    MatplotlibBackend

MATPLOTLIB_VERSION = get_matplotlib_version()


def add_unittests(testsuite, module_name):
    """
    Function to add all available unittests of the module with given name
    (e.g. "obspy.core") to the given unittest TestSuite.
    All submodules in the "tests" directory whose names are starting with
    ``test_`` are added.

    :type testsuite: unittest.TestSuite
    :param testsuite: testsuite to which the tests should be added
    :type module_name: str
    :param module_name: name of the module of which the tests should be added

    .. rubric:: Example
Exemplo n.º 6
0
import os
import re
import shutil
import unittest
import warnings
from distutils.version import LooseVersion

from lxml import etree
import numpy as np

from obspy.core.util.base import NamedTemporaryFile, get_matplotlib_version
from obspy.core.util.misc import CatchOutput, get_untracked_files_from_git, \
    MatplotlibBackend


MATPLOTLIB_VERSION = get_matplotlib_version()
# this dictionary contains the locations of checker routines that determine
# whether the module's tests can be executed or not (e.g. because test server
# is unreachable, necessary ports are blocked, etc.).
# A checker routine should return either an empty string (tests can and will
# be executed) or a message explaining why tests can not be executed (all
# tests of corresponding module will be skipped).
MODULE_TEST_SKIP_CHECKS = {
    'clients.seishub':
        'obspy.clients.seishub.tests.test_client._check_server_availability',
    }
# List of flake8 error codes to ignore. Keep it as small as possible - there
# usually is little reason to fight flake8.
FLAKE8_IGNORE_CODES = [
    # E402 module level import not at top of file
    # This is really annoying when using the standard library import hooks