How to use the datafiles.utils.dedent function in datafiles

To help you get started, we’ve selected a few datafiles examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacebrowning / datafiles / tests / test_patched_methods.py View on Github external
logbreak("Appending to nested list")
        sample.nested.items.append(2)

        expect(read('tmp/sample.yml')) == dedent(
            """
            item: 1
            nested:
              items:
                - 2
            """
        )

        logbreak("Appending to nested list")
        sample.nested.items.append(3)

        expect(read('tmp/sample.yml')) == dedent(
            """
            item: 1
github jacebrowning / datafiles / tests / test_file_inference.py View on Github external
logbreak("Inferring object")
    sample = auto('tmp/sample.yml')

    logbreak("Reading attributes")
    expect(sample.homogeneous_list) == [1, 2]
    expect(sample.heterogeneous_list) == [1, 'abc']
    expect(sample.empty_list) == []

    logbreak("Updating attribute")
    sample.homogeneous_list.append(3.4)
    sample.heterogeneous_list.append(5.6)
    sample.empty_list.append(7.8)

    logbreak("Reading file")
    expect(read('tmp/sample.yml')) == dedent(
        """
        homogeneous_list:
github jacebrowning / datafiles / tests / test_patched_methods.py View on Github external
def with_append_on_nested_dataclass(expect):
        sample = SampleWithNesting(1)

        logbreak("Appending to nested list")
        sample.nested.items.append(2)

        expect(read('tmp/sample.yml')) == dedent(
            """
            item: 1
            nested:
              items:
                - 2
            """
        )

        logbreak("Appending to nested list")
        sample.nested.items.append(3)

        expect(read('tmp/sample.yml')) == dedent(
            """
            item: 1
github jacebrowning / datafiles / tests / test_saving.py View on Github external
def with_initial_values(expect):
        sample = SampleWithNesting('foo', 1.2, {'name': 'bar', 'score': 3.4})

        sample.datafile.save()

        with open('tmp/sample.yml') as f:
            expect(f.read()) == dedent(
                """
                name: foo
github jacebrowning / datafiles / tests / test_saving.py View on Github external
def without_initial_values(sample, expect):
        sample.datafile.save()

        with open('tmp/sample.yml') as f:
            expect(f.read()) == dedent(
                """
                bool_: false
github jacebrowning / datafiles / tests / test_saving.py View on Github external
def with_default_values(expect):
        sample = SampleWithNestingAndDefaults('a')

        sample.datafile.save()

        with open('tmp/sample.yml') as f:
            expect(f.read()) == dedent(
                """
                name: a
github jacebrowning / datafiles / tests / test_patched_methods.py View on Github external
sample.items.append(2)

        expect(read('tmp/sample.yml')) == dedent(
            """
            items:
              - 1
              - 2
            """
        )

        sample.datafile.load()

        logbreak("Appending to list")
        sample.items.append(3)

        expect(read('tmp/sample.yml')) == dedent(
            """
            items: