File: test_configdict.py

package info (click to toggle)
python-plaster-pastedeploy 0.5-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 316 kB
  • sloc: python: 639; makefile: 12
file content (38 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" Tests for plaster_pastedeploy.ConfigDict
"""
import copy                     # noqa: F401
import plaster
import pytest


@pytest.fixture
def loader():
    from plaster_pastedeploy import Loader
    uri = plaster.PlasterURL('pastedeploy+ini', 'development.ini')
    return Loader(uri)


def dict_copy(d):
    return d.copy()


def copy_copy(d):
    return copy.copy(d)


@pytest.mark.parametrize('copier',
                         [dict_copy, copy_copy],
                         ids=lambda f: f.__name__)
def test_copy(copier, loader):
    from plaster_pastedeploy import ConfigDict
    x = []
    global_conf = {}
    configdict = ConfigDict({'x': x}, global_conf, loader)

    duplicate = copier(configdict)

    assert duplicate.items() == configdict.items()
    # check that we got a shallow copy
    assert duplicate['x'] is x
    assert duplicate.global_conf is global_conf
    assert duplicate.loader is loader