Skip to content

Commit

Permalink
Update conftest.py
Browse files Browse the repository at this point in the history
Duplicate code from pint/pint/testsuite/conftest.py.  Ruff and Black conspired to delete simple imports of relevant fixture definitions.

Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com>
  • Loading branch information
MichaelTiemannOSC committed Aug 28, 2023
1 parent d15b25e commit 0a1aad6
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pint_pandas/testsuite/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# pytest fixtures

import pathlib

import pytest

import pint


_TINY = """
yocto- = 1e-24 = y-
zepto- = 1e-21 = z-
atto- = 1e-18 = a-
femto- = 1e-15 = f-
pico- = 1e-12 = p-
nano- = 1e-9 = n-
micro- = 1e-6 = µ- = μ- = u-
milli- = 1e-3 = m-
centi- = 1e-2 = c-
deci- = 1e-1 = d-
deca- = 1e+1 = da- = deka-
hecto- = 1e2 = h-
kilo- = 1e3 = k-
mega- = 1e6 = M-
giga- = 1e9 = G-
tera- = 1e12 = T-
peta- = 1e15 = P-
exa- = 1e18 = E-
zetta- = 1e21 = Z-
yotta- = 1e24 = Y-
meter = [length] = m = metre
second = [time] = s = sec
angstrom = 1e-10 * meter = Å = ångström = Å
minute = 60 * second = min
"""


@pytest.fixture(scope="session")
def tmppath_factory(tmpdir_factory) -> pathlib.Path:
tmp = tmpdir_factory.mktemp("pint")
return pathlib.Path(tmp)


@pytest.fixture(scope="session")
def tiny_definition_file(tmppath_factory: pathlib.Path) -> pathlib.Path:
folder = tmppath_factory / "definitions"
folder.mkdir(exist_ok=True, parents=True)
path = folder / "tiny.txt"
if not path.exists():
path.write_text(_TINY, encoding="utf-8")
return path


@pytest.fixture
def registry_empty():
return pint.UnitRegistry(None)


@pytest.fixture
def registry_tiny(tiny_definition_file: pathlib.Path):
return pint.UnitRegistry(tiny_definition_file)

0 comments on commit 0a1aad6

Please sign in to comment.