Esempio n. 1
0
def test_flakes(snapshot, tmpdir):
    output = str(tmpdir.join("test"))
    # generate the (three) flakes
    run_flake({
        "output": output,
        "radius": 7,
    })
    snapshot.assert_match(FileSnapshot(f"{output}-a.vasp"))
    snapshot.assert_match(FileSnapshot(f"{output}-b.vasp"))
    snapshot.assert_match(FileSnapshot(f"{output}-c.vasp"))
Esempio n. 2
0
def test_multiple_files(snapshot, tmpdir):
    """
    Each file is stored separately with the snapshot's name inside the module's file snapshots folder.
    """
    temp_file1 = tmpdir.join('example1.txt')
    temp_file1.write('Hello, world 1!')
    snapshot.assert_match(FileSnapshot(str(temp_file1)))

    temp_file1 = tmpdir.join('example2.txt')
    temp_file1.write('Hello, world 2!')
    snapshot.assert_match(FileSnapshot(str(temp_file1)))
Esempio n. 3
0
def test_file(snapshot, tmpdir):
    """
    Test a file snapshot. The file contents will be saved in a sub-folder of the snapshots folder. Useful for large
    files (e.g. media files) that aren't suitable for storage as text inside the snap_***.py file.
    """
    temp_file = tmpdir.join('example.txt')
    temp_file.write('Hello, world!')
    snapshot.assert_match(FileSnapshot(str(temp_file)))
Esempio n. 4
0
def test_holidata_produces_holidays_for_locale_and_year(
        snapshot, tmpdir, locale):
    temp_file = tmpdir.join('{}.{}.py'.format(locale.locale, locale.year))

    export_data = [h.as_dict() for h in locale.holidays]
    export_data.sort(key=lambda x: x['date'])
    temp_file.write(Formatter().format(export_data, 0))

    snapshot.assert_match(FileSnapshot(str(temp_file)))
    def _check_html(self, name, html):
        print('Cheking fixture named: %s' % name)

        with TemporaryDirectory() as tmpdir:
            data = image_encoding.html_to_png(html)
            image = Image.open(data)

            temp_file_name = os.path.join(tmpdir, '%s.png' % name)
            image.save(temp_file_name, format='PNG')
            self.assertMatchSnapshot(FileSnapshot(temp_file_name), name)
Esempio n. 6
0
def test_gif(snapshot, datadir):
    run({
        "input": datadir.join("POSCAR"),
        "eigs": datadir.join("gamma-dynmat.npz"),
        "supercell": [1, 1, 1],
        "config": None,
        "output": datadir,
        "gif": 3,
        "parallel": None,
        "all_gifs": False,
    })

    output = str(datadir.join("mode_3.gif"))
    snapshot.assert_match(FileSnapshot(output))
Esempio n. 7
0
def test_cnts(snapshot, tmpdir):
    for args in [{
            "n": 5,
            "m": 5,
    }, {
            "n": 6,
            "m": 0,
    }, {
            "n": 2,
            "m": 5,
    }]:
        args["output"] = str(tmpdir.join("test.vasp"))
        # generate the CNT
        run_cnt(args)
        snapshot.assert_match(FileSnapshot(args["output"]))
Esempio n. 8
0
def test_svgs(snapshot, datadir):
    # TODO: also check phonopy input ("qpoints.yaml")
    run({
        "input": datadir.join("POSCAR"),
        "eigs": datadir.join("gamma-dynmat.npz"),
        "supercell": [1, 1, 1],
        "config": None,
        "output": datadir,
        "gif": False,
        "parallel": None,
        "all_gifs": False,
    })

    for f in ["mode_3.svg", "mode_20.svg"]:
        output = str(datadir.join(f))
        snapshot.assert_match(FileSnapshot(output))
Esempio n. 9
0
def test_gnrs(snapshot, tmpdir):
    for args in [{
            "width": 4,
            "length": 12,
            "periodic": False,
            "zigzag": False,
            "no_hydrogen": False,
    }, {
            "width": 6,
            "length": 1,
            "periodic": True,
            "zigzag": False,
            "no_hydrogen": False,
    }, {
            "width": 3,
            "length": 1,
            "periodic": True,
            "zigzag": True,
            "no_hydrogen": False,
    }]:
        args["output"] = str(tmpdir.join("test.vasp"))
        # generate the GNR
        run_gnr(args)
        snapshot.assert_match(FileSnapshot(args["output"]))
Esempio n. 10
0
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import GenericRepr, Snapshot
from snapshottest.file import FileSnapshot

snapshots = Snapshot()

snapshots['test_me_endpoint 1'] = {'url': '/me'}

snapshots['test_unicode 1'] = 'pépère'

snapshots['test_object 1'] = GenericRepr('SomeObject(3)')

snapshots['test_file 1'] = FileSnapshot('snap_test_demo/test_file 1.txt')

snapshots['test_multiple_files 1'] = FileSnapshot(
    'snap_test_demo/test_multiple_files 1.txt')

snapshots['test_multiple_files 2'] = FileSnapshot(
    'snap_test_demo/test_multiple_files 2.txt')

snapshots['test_nested_objects dict'] = {'key': GenericRepr('#')}

snapshots['test_nested_objects defaultdict'] = {'key': [GenericRepr('#')]}

snapshots['test_nested_objects list'] = [GenericRepr('#')]

snapshots['test_nested_objects tuple'] = (GenericRepr('#'), )
Esempio n. 11
0
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import Snapshot
from snapshottest.file import FileSnapshot

snapshots = Snapshot()

snapshots['test_svgs 1'] = FileSnapshot('snap_test_modeplot/test_svgs 1.svg')

snapshots['test_svgs 2'] = FileSnapshot('snap_test_modeplot/test_svgs 2.svg')

snapshots['test_gif 1'] = FileSnapshot('snap_test_modeplot/test_gif 1.gif')
Esempio n. 12
0
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import Snapshot
from snapshottest.file import FileSnapshot

snapshots = Snapshot()

snapshots['test_diff_images 1'] = FileSnapshot(
    'snap_test_image_utils/test_diff_images 1.bmp')
Esempio n. 13
0
def test1(snapshot):
    path_save = "tests/data/iris_info.csv"
    df: pd.DataFrame = pd.read_csv("data/iris.csv")
    df.describe().reset_index().to_csv(path_save)
    snapshot.assert_match(FileSnapshot(path_save), "iris_info")
Esempio n. 14
0
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import Snapshot
from snapshottest.file import FileSnapshot

snapshots = Snapshot()

snapshots[
    'ImageCodingSnapshotCase::test_snapshot_fixtures hello_world'] = FileSnapshot(
        'snap_test_image_coding_snapshots/ImageCodingSnapshotCase::test_snapshot_fixtures hello_world.png'
    )

snapshots[
    'ImageCodingSnapshotCase::test_snapshot_template_fixtures hello_world'] = FileSnapshot(
        'snap_test_image_coding_snapshots/ImageCodingSnapshotCase::test_snapshot_template_fixtures hello_world.png'
    )