How to use is_ method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_filters.py

Source:test_filters.py Github

copy

Full Screen

1from hamcrest import assert_that, is_2from lib.filters import number_as_magnitude, number_as_financial_magnitude, join_url_parts, string_as_static_url, digest, number_as_grouped_number, number_as_percentage_change3def test_number_as_magnitude():4 assert_that(number_as_magnitude(1.23), is_("1.23"))5 assert_that(number_as_magnitude(1.234), is_("1.23"))6 assert_that(number_as_magnitude(1.236), is_("1.24"))7 assert_that(number_as_magnitude(12.3), is_("12.3"))8 assert_that(number_as_magnitude(12.34), is_("12.3"))9 assert_that(number_as_magnitude(12.36), is_("12.4"))10 assert_that(number_as_magnitude(123), is_("123"))11 assert_that(number_as_magnitude(123.4), is_("123"))12 assert_that(number_as_magnitude(123.6), is_("124"))13 assert_that(number_as_magnitude(1230), is_("1.23k"))14 assert_that(number_as_magnitude(1234), is_("1.23k"))15 assert_that(number_as_magnitude(1236), is_("1.24k"))16 assert_that(number_as_magnitude(12300), is_("12.3k"))17 assert_that(number_as_magnitude(12340), is_("12.3k"))18 assert_that(number_as_magnitude(12360), is_("12.4k"))19 assert_that(number_as_magnitude(123000), is_("123k"))20 assert_that(number_as_magnitude(123400), is_("123k"))21 assert_that(number_as_magnitude(123600), is_("124k"))22 assert_that(number_as_magnitude(1230000), is_("1.23m"))23 assert_that(number_as_magnitude(1234000), is_("1.23m"))24 assert_that(number_as_magnitude(1236000), is_("1.24m"))25 assert_that(number_as_magnitude(12300000), is_("12.3m"))26 assert_that(number_as_magnitude(12340000), is_("12.3m"))27 assert_that(number_as_magnitude(12360000), is_("12.4m"))28 assert_that(number_as_magnitude(123000000), is_("123m"))29 assert_that(number_as_magnitude(123400000), is_("123m"))30 assert_that(number_as_magnitude(123600000), is_("124m"))31 assert_that(number_as_magnitude(1230000000), is_("1.23bn"))32 assert_that(number_as_magnitude(1234000000), is_("1.23bn"))33 assert_that(number_as_magnitude(1236000000), is_("1.24bn"))34 assert_that(number_as_magnitude(12300000000), is_("12.3bn"))35 assert_that(number_as_magnitude(12340000000), is_("12.3bn"))36 assert_that(number_as_magnitude(12360000000), is_("12.4bn"))37 assert_that(number_as_magnitude(123000000000), is_("123bn"))38 assert_that(number_as_magnitude(123400000000), is_("123bn"))39 assert_that(number_as_magnitude(123600000000), is_("124bn"))40def test_number_as_financial_magnitude():41 assert_that(number_as_financial_magnitude(1.23), is_("1.23"))42 assert_that(number_as_financial_magnitude(1.234), is_("1.23"))43 assert_that(number_as_financial_magnitude(1.236), is_("1.24"))44 assert_that(number_as_financial_magnitude(12.33), is_("12.33"))45 assert_that(number_as_financial_magnitude(12.334), is_("12.33"))46 assert_that(number_as_financial_magnitude(12.336), is_("12.34"))47 assert_that(number_as_financial_magnitude(123), is_("123"))48 assert_that(number_as_financial_magnitude(123.4), is_("123"))49 assert_that(number_as_financial_magnitude(123.6), is_("124"))50 assert_that(number_as_financial_magnitude(1230), is_("1.23k"))51 assert_that(number_as_financial_magnitude(1234), is_("1.23k"))52 assert_that(number_as_financial_magnitude(1236), is_("1.24k"))53 assert_that(number_as_financial_magnitude(12300), is_("12.3k"))54 assert_that(number_as_financial_magnitude(12340), is_("12.3k"))55 assert_that(number_as_financial_magnitude(12360), is_("12.4k"))56 assert_that(number_as_financial_magnitude(123000), is_("123k"))57 assert_that(number_as_financial_magnitude(123400), is_("123k"))58 assert_that(number_as_financial_magnitude(123600), is_("124k"))59 assert_that(number_as_financial_magnitude(1230000), is_("1.23m"))60 assert_that(number_as_financial_magnitude(1234000), is_("1.23m"))61 assert_that(number_as_financial_magnitude(1236000), is_("1.24m"))62 assert_that(number_as_financial_magnitude(12300000), is_("12.3m"))63 assert_that(number_as_financial_magnitude(12340000), is_("12.3m"))64 assert_that(number_as_financial_magnitude(12360000), is_("12.4m"))65 assert_that(number_as_financial_magnitude(123000000), is_("123m"))66 assert_that(number_as_financial_magnitude(123400000), is_("123m"))67 assert_that(number_as_financial_magnitude(123600000), is_("124m"))68 assert_that(number_as_financial_magnitude(1230000000), is_("1.23bn"))69 assert_that(number_as_financial_magnitude(1234000000), is_("1.23bn"))70 assert_that(number_as_financial_magnitude(1236000000), is_("1.24bn"))71 assert_that(number_as_financial_magnitude(12300000000), is_("12.3bn"))72 assert_that(number_as_financial_magnitude(12340000000), is_("12.3bn"))73 assert_that(number_as_financial_magnitude(12360000000), is_("12.4bn"))74 assert_that(number_as_financial_magnitude(123000000000), is_("123bn"))75 assert_that(number_as_financial_magnitude(123400000000), is_("123bn"))76 assert_that(number_as_financial_magnitude(123600000000), is_("124bn"))77def test_number_as_grouped_number():78 assert_that(number_as_grouped_number(123456789), is_("123,456,789"))79 assert_that(number_as_grouped_number(123), is_("123"))80 assert_that(number_as_grouped_number(4567.22), is_("4,567"))81 assert_that(number_as_grouped_number(4567.98), is_("4,568"))82 assert_that(number_as_grouped_number("not a number"), is_(""))83def test_number_as_percentage_change():84 assert_that(number_as_percentage_change(None), is_("0%"))85 assert_that(number_as_percentage_change(1.0), is_("0%"))86 assert_that(number_as_percentage_change(1.00001), is_("0%"))87 assert_that(number_as_percentage_change(0.999991), is_("0%"))88 assert_that(number_as_percentage_change(0.0), is_("-100%"))89 assert_that(number_as_percentage_change(2.0), is_("+100%"))90 assert_that(number_as_percentage_change(1.1234567), is_("+12.35%"))91 assert_that(number_as_percentage_change(0.1234567), is_("-87.65%"))92class Test_join_url_parts(object):93 def test_string_as_link(self):94 assert_that(95 join_url_parts('/', 'some/path'),96 is_('/some/path'))97 def test_string_as_link_with_user_defined_path_prefix(self):98 assert_that(99 join_url_parts('/custom/prefix/', 'some/path'),100 is_('/custom/prefix/some/path'))101 def test_string_as_link_adds_trailing_slash_after_prefix(self):102 assert_that(103 join_url_parts('/custom/prefix', 'some/path'),104 is_('/custom/prefix/some/path'))105 def test_string_as_link_does_not_add_double_slashes(self):106 assert_that(107 join_url_parts('/custom/prefix/', '/some/path'),108 is_('/custom/prefix/some/path'))109class Test_string_as_static_url:110 def setUp(self):111 digest.set_digests({})112 def test_return_url_with_digest(self):113 digest.set_digests({114 'asset.css': 'asset-1425361275412.css'115 })116 assert_that(117 string_as_static_url('asset.css'),118 is_('https://assets.digital.cabinet-office.gov.uk/static/asset-1425361275412.css')119 )120 def test_fallback_to_plain_url_when_digest_is_unknown(self):121 assert_that(122 string_as_static_url('asset.css'),123 is_('https://assets.digital.cabinet-office.gov.uk/static/asset.css')...

Full Screen

Full Screen

test_tracked_path.py

Source:test_tracked_path.py Github

copy

Full Screen

1#!/usr/bin/env false2"""TODO: Write3"""4# Internal packages (absolute references, distributed with Python)5from pathlib import Path6from pathlib import PosixPath7# External packages (absolute references, NOT distributed with Python)8from pytest import raises9# Library modules (absolute references, NOT packaged, in project)10from utility import my_assert as is_11from utility.tracked_path import TrackedPath12# Project modules (relative references, NOT packaged, in project)13def test_path():14 assert is_.not_none(Path())15 with raises(TypeError):16 Path(None)17 a = Path("")18 assert is_.not_none(a)19 assert is_.equal(a.__fspath__(), ".")20 assert is_.equal(repr(a), "PosixPath('.')")21 assert is_.equal(str(a), ".")22 assert is_.relative_path(a)23 a = Path("Test")24 assert is_.not_none(a)25 assert is_.equal(a.__fspath__(), "Test")26 assert is_.equal(repr(a), "PosixPath('Test')")27 assert is_.equal(str(a), "Test")28 assert is_.relative_path(a)29 a = Path("/Test")30 assert is_.not_none(a)31 assert is_.equal(a.__fspath__(), "/Test")32 assert is_.equal(repr(a), "PosixPath('/Test')")33 assert is_.equal(str(a), "/Test")34 assert is_.absolute_path(a)35 b = a / Path("123")36 assert is_.not_none(b)37 assert is_.equal(b.__fspath__(), "/Test/123")38 assert is_.equal(repr(b), "PosixPath('/Test/123')")39 assert is_.equal(str(b), "/Test/123")40 assert is_.absolute_path(b)41def test_tracked_path():42 with raises(TypeError):43 TrackedPath()44 with raises(TypeError):45 TrackedPath(None)46 with raises(AssertionError):47 TrackedPath(None, None)48 with raises(AssertionError):49 TrackedPath(None, None, None)50 with raises(AssertionError):51 TrackedPath("Test", "Test", "Test")52 with raises(AssertionError):53 TrackedPath("Test", "Test", Path())54 with raises(AssertionError):55 TrackedPath("Test", Path(), "Test")56 with raises(AssertionError):57 TrackedPath("Test", Path(), Path())58 with raises(AssertionError):59 TrackedPath("Test", "123", "abc")60 a = TrackedPath("Test", "/123")61 assert is_.not_none(a)62 assert is_.equal(a, PosixPath("/123"))63 assert is_.equal(a.__fspath__(), "/123")64 assert is_.equal(65 repr(a), "TrackedPath('Test', PosixPath('/123'), PosixPath('.'))"66 )67 assert is_.equal(str(a), a)68 assert is_.equal(str(a), a.__fspath__())69 assert is_.equal(a.for_log(), "'Test' path '.'")70 assert is_.absolute_path(a.top)71 assert is_.equal(a.top, a)72 assert is_.relative_path(a.subpath)73 assert is_.equal(a.subpath, Path("."))74 assert is_.equal(a.basename, "")75 with raises(ValueError):76 a.parent77 b = TrackedPath("Test", "/123", "abc")78 assert is_.not_none(b)79 assert is_.equal(b, PosixPath("/123/abc"))80 assert is_.equal(b.__fspath__(), "/123/abc")81 assert is_.equal(82 repr(b), "TrackedPath('Test', PosixPath('/123'), PosixPath('abc'))"83 )84 assert is_.equal(str(b), b)85 assert is_.equal(str(b), b.__fspath__())86 assert is_.equal(b.for_log(), "'Test' path 'abc'")87 assert is_.absolute_path(b.top)88 assert is_.equal(b.top, a)89 assert is_.relative_path(b.subpath)90 assert is_.equal(b.subpath, Path("."))91 assert is_.equal(b.basename, "abc")92 assert is_.equal(b.parent, a)93 c = Path("/123/abc/xyz")94 d = b.for_path(c)95 assert is_.not_none(d)96 assert is_.equal(d, PosixPath("/123/abc/xyz"))97 assert is_.equal(d.__fspath__(), "/123/abc/xyz")98 assert is_.equal(99 repr(d), "TrackedPath('Test', PosixPath('/123'), PosixPath('abc/xyz'))"100 )101 assert is_.equal(str(d), d)102 assert is_.equal(str(d), d.__fspath__())103 assert is_.equal(d.for_log(), "'Test' path 'abc/xyz'")104 assert is_.absolute_path(d.top)105 assert is_.equal(d.top, a)106 assert is_.relative_path(d.subpath)107 assert is_.equal(d.subpath, Path("abc"))108 assert is_.equal(d.basename, "xyz")109 assert is_.equal(d.parent, b)110 e = d / "def.ghi"111 assert is_.not_none(e)112 assert is_.equal(e, PosixPath("/123/abc/xyz/def.ghi"))113 assert is_.equal(e.__fspath__(), "/123/abc/xyz/def.ghi")114 assert is_.equal(115 repr(e),116 "TrackedPath('Test', PosixPath('/123'), PosixPath('abc/xyz/def.ghi'))",117 )118 assert is_.equal(str(e), e)119 assert is_.equal(str(e), e.__fspath__())120 assert is_.equal(e.for_log(), "'Test' path 'abc/xyz/def.ghi'")121 assert is_.absolute_path(e.top)122 assert is_.equal(e.top, a)123 assert is_.relative_path(e.subpath)124 assert is_.equal(e.subpath, Path("abc/xyz"))125 assert is_.equal(e.basename, "def.ghi")126 assert is_.equal(e.parent, d)127 f = b / None128 assert is_.not_none(f)129 assert is_.equal(f, PosixPath("/123/abc"))130 assert is_.equal(f.__fspath__(), "/123/abc")131 assert is_.equal(132 repr(f), "TrackedPath('Test', PosixPath('/123'), PosixPath('abc'))"133 )134 assert is_.equal(str(f), f)135 assert is_.equal(str(f), f.__fspath__())136 assert is_.equal(f.for_log(), "'Test' path 'abc'")137 assert is_.absolute_path(f.top)138 assert is_.equal(f.top, a)139 assert is_.relative_path(f.subpath)140 assert is_.equal(f.subpath, Path())141 assert is_.equal(f.basename, "abc")142 assert is_.equal(f.parent, a)143 g = b / ""144 assert is_.not_none(g)145 assert is_.equal(g, PosixPath("/123/abc"))146 assert is_.equal(g.__fspath__(), "/123/abc")147 assert is_.equal(148 repr(g), "TrackedPath('Test', PosixPath('/123'), PosixPath('abc'))"149 )150 assert is_.equal(str(g), g.__fspath__())151 assert is_.equal(g.for_log(), "'Test' path 'abc'")152 assert is_.absolute_path(g.top)153 assert is_.equal(g.top, a)154 assert is_.relative_path(g.subpath)155 assert is_.equal(g.subpath, Path())156 assert is_.equal(g.basename, "abc")157 assert is_.equal(g.parent, a)158 h = b / Path()159 assert is_.not_none(h)160 assert is_.equal(h, PosixPath("/123/abc"))161 assert is_.equal(h.__fspath__(), "/123/abc")162 assert is_.equal(163 repr(h), "TrackedPath('Test', PosixPath('/123'), PosixPath('abc'))"164 )165 assert is_.equal(str(h), h)166 assert is_.equal(str(h), h.__fspath__())167 assert is_.equal(h.for_log(), "'Test' path 'abc'")168 assert is_.absolute_path(h.top)169 assert is_.equal(h.top, a)170 assert is_.relative_path(h.subpath)171 assert is_.equal(h.subpath, Path())172 assert is_.equal(h.basename, "abc")173 assert is_.equal(h.parent, a)174"""DisabledContent...

Full Screen

Full Screen

test_config_probe.py

Source:test_config_probe.py Github

copy

Full Screen

...6class TestConfigProbe(unittest.TestCase):7 def test_single_file(self):8 config = probe(path=_dir("single-file"),9 patterns=["stuff.yaml"])10 assert_that(config.key, is_("stuff-value"))11 assert_that(config.fruits, is_(["Apple", "Orange"]))12 def test_single_file_with_namespace(self):13 config = probe(path=_dir("single-file-with-namespace"),14 patterns=["(*).json"])15 assert_that(config.stuff.key, is_("stuff-value"))16 def test_single_file_with_namespace_with_wrong_key(self):17 config = probe(path=_dir("single-file-with-namespace"),18 patterns=["(*).json"])19 with self.assertRaises(ConfigNotFound):20 print(config.stuff.key_inexistant)21 def test_single_file_multiple_level_raising_or_not(self):22 config = probe(path=_dir("multi-level-files"),23 patterns=["(*)/(*).yaml", "(*)/subdir/(*).yaml"])24 assert_that(config.ns1.stuff.we.need.more.cowbell, is_("ok"))25 with self.assertRaises(ConfigNotFound):26 print(config.ns1.stuff.we.need.less.cowbell)27 def test_two_files_with_subdir_namespace(self):28 config = probe(path=_dir("two-files-with-subdir-namespace"),29 patterns=["(*)/(*).yaml"])30 assert_that(config.ns1.stuff.key1, is_("stuff from ns1"))31 assert_that(config.ns2.stuff.key2, is_("stuff from ns2"))32 def test_only_starred_parts_are_namespaced(self):33 config = probe(path=_dir("two-files-with-subdir-namespace"),34 patterns=["(*)/stuff.yaml"])35 assert_that(config.ns1.key1, is_("stuff from ns1"))36 assert_that(config.ns2.key2, is_("stuff from ns2"))37 def test_using_only_a_star_does_not_count_toward_namespacing(self):38 config = probe(path=_dir("two-files-with-subdir-namespace"),39 patterns=["*/stuff.yaml"])40 assert_that(config.key1, is_("stuff from ns1"))41 assert_that(config.key2, is_("stuff from ns2"))42 def test_multiple_patterns(self):43 config = probe(path=_dir("two-files-with-subdir-namespace"),44 patterns=["ns1/(*).yaml", "(*)/stuff.yaml"])45 assert_that(config.stuff.key1, is_("stuff from ns1"))46 assert_that(config.ns2.key2, is_("stuff from ns2"))47 def test_multiple_patterns_on_same_namespaces_should_merge_recursively(self):48 config = probe(path=_dir("multi-level-files"),49 patterns=["(*)/(*).yaml", "(*)/subdir/(*).yaml"])50 assert_that(config.ns1.stuff.content1.key1, is_("value1"))51 assert_that(config.ns1.stuff.content2.key2, is_("value2"))52 def test_pattern_order_defines_which_files_have_the_authority(self):53 config = probe(path=_dir("key-override"),54 patterns=["file1.yaml", "file2.yaml"])55 assert_that(config.key, is_("value2"))56 config = probe(path=_dir("key-override"),57 patterns=["file2.yaml", "file1.yaml"])58 assert_that(config.key, is_("value1"))59 def test_yaml_dict_are_merged_list_arent(self):60 config = probe(path=_dir("dict-merge"),61 patterns=["file1.yaml", "file2.yaml"])62 assert_that(config.mydict.common_key, is_("value2"))63 assert_that(config.mydict.only_in_1, is_("value1"))64 assert_that(config.mydict.only_in_2, is_("value2"))65 assert_that(config.mydict.subdict.common_list, is_(["a2", "b2"]))66 assert_that(config.mydict.subdict.only_in_1, is_("value1"))67 assert_that(config.mydict.subdict.only_in_2, is_("value2"))68 config = probe(path=_dir("dict-merge"),69 patterns=["file2.yaml", "file1.yaml"])70 assert_that(config.mydict.common_key, is_("value1"))71 assert_that(config.mydict.only_in_1, is_("value1"))72 assert_that(config.mydict.only_in_2, is_("value2"))73 assert_that(config.mydict.subdict.common_list, is_(["a1", "b1"]))74 assert_that(config.mydict.subdict.only_in_1, is_("value1"))75 assert_that(config.mydict.subdict.only_in_2, is_("value2"))76 def test_dict_should_behave_as_dict(self):77 config = probe(path=_dir("single-file"),78 patterns=["(*).yaml"])79 assert_that(config["stuff"]["key"], is_("stuff-value"))80 assert_that(dict(config), has_key('stuff'))81 assert_that(dict(**config), has_key('stuff'))82 assert_that(dict(config.stuff), has_key('key'))83 assert_that(dict(**config.stuff), has_key('key'))84 def test_support_for_empty_files(self):85 probe(path=_dir("empty-files"), patterns=["*.*"])86 def test_support_absolute_paths_outside_base_dir(self):87 config = probe(path=_dir("single-file-with-namespace"), patterns=[88 "{}/(*)/(*)/stuff.yaml".format(os.path.dirname(__file__))89 ])90 assert_that(config['two-files-with-subdir-namespace'].ns1.key1, is_("stuff from ns1"))91 assert_that(config['two-files-with-subdir-namespace'].ns2.key2, is_("stuff from ns2"))92 def test_fake_probe(self):93 config = fake_probe({94 "key": "value",95 "key2": [96 {"hey": "ho"}97 ]98 })99 assert_that(config.key, is_("value"))100 assert_that(config.key2[0].hey, is_("ho"))101 with self.assertRaises(ConfigNotFound):102 print(config.unknown)103def _dir(name):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful