예제 #1
0
파일: test_local.py 프로젝트: paskma/py
 def test_tmproot(self):
     d = local.mkdtemp()
     tmproot = local.get_temproot()
     try:
         assert d.check(dir=1)
         assert d.dirpath() == tmproot
     finally:
         d.remove(rec=1)
예제 #2
0
 def test_tmproot(self):
     d = local.mkdtemp()
     tmproot = local.get_temproot()
     try:
         assert d.check(dir=1)
         assert d.dirpath() == tmproot
     finally:
         d.remove(rec=1)
예제 #3
0
def get_pytest_roottmpdir():
    """Returns the temporary root directory of pytest (usually something like
       "/tmp/pytest-of-$USER/"

    :return: root temporary directory of pytest
    :rtype: :class:`py.path.local`
    """
    temproot = local.get_temproot()
    user = get_user()
    rootdir = temproot.join('pytest-of-%s' % user) if user else temproot
    rootdir.ensure(dir=True)
    return rootdir
예제 #4
0

# Add the pep8 and incremental markers
def pytest_configure(config):
    config.addinivalue_line("markers", "pep8: Checks for PEP8 compliancy.")
    config.addinivalue_line(
        "markers", "incremental: Mark test suite to xfail all "
        "remaining tests when one fails.")


# This introduces a marker that auto-fails tests if a previous one failed
def pytest_runtest_makereport(item, call):
    if "incremental" in item.keywords:
        if (call.excinfo is not None
                and call.excinfo.type is not _pytest.outcomes.Skipped):
            parent = item.parent
            parent._previousfailed = item


# This makes every marked test auto-fail if a previous one failed as well
def pytest_runtest_setup(item):
    if "incremental" in item.keywords:
        previousfailed = getattr(item.parent, "_previousfailed", None)
        if previousfailed is not None:
            pytest.xfail("Previous test failed (%s)" % (previousfailed.name))


# %% PYTEST SETTINGS
# Set the current working directory to the temporary directory
local.get_temproot().chdir()
예제 #5
0
import hickle as hkl
from astropy.units import Quantity
from astropy.time import Time
from astropy.coordinates import Angle, SkyCoord
from astropy.constants import Constant, EMConstant, G
from astropy.table import Table
import numpy as np
from py.path import local

# Set the current working directory to the temporary directory
local.get_temproot().chdir()

def test_astropy_quantity():

    for uu in ['m^3', 'm^3 / s', 'kg/pc']:
        a = Quantity(7, unit=uu)

        hkl.dump(a, "test_ap.h5")
        b = hkl.load("test_ap.h5")

        assert a == b
        assert a.unit == b.unit

        a *= a
        hkl.dump(a, "test_ap.h5")
        b = hkl.load("test_ap.h5")
        assert a == b
        assert a.unit == b.unit

def TODO_test_astropy_constant():
        hkl.dump(G, "test_ap.h5")