def test_minimum_version(mocked_version, offline, request): """Stamp a style file with a minimum required version, to indicate new features or breaking changes.""" assert_conditions(mocked_version == "0.5.3") ProjectMock(request).named_style( "parent", """ [nitpick.styles] include = "child.toml" ["pyproject.toml".tool.black] line-length = 100 """, ).named_style( "child", """ [nitpick] minimum_version = "1.0" """, ).pyproject_toml(""" [tool.nitpick] style = "parent" [tool.black] line-length = 100 """).flake8(offline=offline).assert_single_error( "NIP203 The style file you're using requires nitpick>=1.0 (you have 0.5.3). Please upgrade" )
def test_get_subclasses(): """Test subclasses.""" # pylint: disable=missing-docstring,too-few-public-methods class Vehicle: pass class Car(Vehicle): pass class Audi(Car): pass class Bicycle(Vehicle): pass assert_conditions(get_subclasses(Vehicle) == [Car, Audi, Bicycle])
def test_merge_dicts_extending_lists(): """Merge dictionaries extending lists.""" merged = MergeDict({"parent": {"brother": 1, "sister": 2}}) merged.add({"parent": {"other": 3}}) assert_conditions( merged.merge() == {"parent": { "brother": 1, "sister": 2, "other": 3 }}) merged = MergeDict( {"box": { "colors": ["blue", "yellow"], "cutlery": ("fork", ) }}) merged.add({"box": {"colors": ("white", ), "cutlery": ["knife", "spoon"]}}) assert_conditions( merged.merge() == { "box": { "colors": ["blue", "yellow", "white"], "cutlery": ["fork", "knife", "spoon"] } })