25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
calculate-utils-4-lib/conftest.py

181 satır
8.0 KiB

import pytest
from collections import OrderedDict
@pytest.fixture(scope='function')
def StringDictionaries():
ParamLine1 = OrderedDict({'parameter name1': 'value1'})
ParamLine2 = OrderedDict({'parameter name2': 'value2'})
ParamLine3 = OrderedDict({'parameter name3': 'value3'})
Section1 = OrderedDict({'section name1': OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({'section name2': OrderedDict(**ParamLine1,
**ParamLine2)})
Section3 = OrderedDict({'section name3': OrderedDict(**ParamLine3)})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**Section3)
ResultDictionary = OrderedDict(**Section1, **Section2, **Section3)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def TupleDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLine3 = OrderedDict({('', 'parameter name3'): 'value3'})
Section1 = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({('', 'section name2'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section3 = OrderedDict({('', 'section name3'): OrderedDict(**ParamLine3)})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**Section3)
ResultDictionary = OrderedDict(**Section1, **Section2, **Section3)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def MergeSectionDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLine3 = OrderedDict({('', 'parameter name3'): 'value3'})
Section1 = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({('', 'section name2'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2Add = OrderedDict({('', 'section name2'):
OrderedDict(**ParamLine3)})
Section2Added = OrderedDict({('', 'section name2'):
OrderedDict(**ParamLine1,
**ParamLine2,
**ParamLine3)})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**Section2Add)
ResultDictionary = OrderedDict(**Section1, **Section2Added)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def ChangeParameterDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLine3 = OrderedDict({('', 'parameter name3'): 'value3'})
ParamLine2New = OrderedDict({('', 'parameter name2'): 'NewValue'})
ParamLine3New = OrderedDict({('', 'parameter name3'): 'OtherValue'})
Section = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2,
**ParamLine3)})
SectionNew = OrderedDict({('', 'section name1'):
OrderedDict(**ParamLine1,
**ParamLine2New,
**ParamLine3New)})
OriginalDictionary = OrderedDict(**Section)
TemplateDictionary = OrderedDict(**SectionNew)
ResultDictionary = TemplateDictionary
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def DeleteSectionDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
Section1 = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({('', 'section name2'): OrderedDict(**ParamLine1,
**ParamLine2)})
SectionDel = OrderedDict({('!', 'section name2'): OrderedDict()})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**SectionDel)
ResultDictionary = OrderedDict(**Section1)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def ReplaceSectionDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLine3 = OrderedDict({('', 'parameter name3'): 'value3'})
ParamLine4 = OrderedDict({('', 'parameter name4'): 'value4'})
Section1 = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({('', 'section name2'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2Replace = OrderedDict({('-', 'section name2'):
OrderedDict(**ParamLine3, **ParamLine4)})
Section2Replaced = OrderedDict({('', 'section name2'):
OrderedDict(**ParamLine3, **ParamLine4)})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**Section2Replace)
ResultDictionary = OrderedDict(**Section1, **Section2Replaced)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def DeleteParameterDictionaries():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLineDel = OrderedDict({('!', 'parameter name2'): 'value2'})
Section1 = OrderedDict({('', 'section name1'): OrderedDict(**ParamLine1,
**ParamLine2)})
Section2 = OrderedDict({('', 'section name2'): OrderedDict(**ParamLine1,
**ParamLine2)})
SectionDel = OrderedDict({('', 'section name2'):
OrderedDict(**ParamLineDel)})
SectionAfterDel = OrderedDict({('', 'section name2'):
OrderedDict(**ParamLine1)})
OriginalDictionary = OrderedDict(**Section1, **Section2)
TemplateDictionary = OrderedDict(**SectionDel)
ResultDictionary = OrderedDict(**Section1, **SectionAfterDel)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
@pytest.fixture(scope='function')
def DictionariesWithoutSections():
ParamLine1 = OrderedDict({('', 'parameter name1'): 'value1'})
ParamLine2 = OrderedDict({('', 'parameter name2'): 'value2'})
ParamLine3 = OrderedDict({('', 'parameter name3'): 'value3'})
ParamLineDel = OrderedDict({('!', 'parameter name2'): ''})
OriginalDictionary = OrderedDict(**ParamLine1, **ParamLine2)
TemplateDictionary = OrderedDict(**ParamLine3, **ParamLineDel)
ResultDictionary = OrderedDict(**ParamLine1, **ParamLine3)
return (OriginalDictionary, TemplateDictionary, ResultDictionary)
import pytest
def pytest_addoption(parser):
parser.addoption(
"--chroot-test", action="store_true", default=False, help="run chroot tests"
)
def pytest_collection_modifyitems(config, items):
if config.getoption("--chroot-test"):
return
skip_chroot = pytest.mark.skip(reason="need --chroot option to run")
for item in items:
if "chroot" in item.keywords:
item.add_marker(skip_chroot)