當前位置: 首頁>>代碼示例>>Python>>正文


Python matchers.LessThan方法代碼示例

本文整理匯總了Python中testtools.matchers.LessThan方法的典型用法代碼示例。如果您正苦於以下問題:Python matchers.LessThan方法的具體用法?Python matchers.LessThan怎麽用?Python matchers.LessThan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在testtools.matchers的用法示例。


在下文中一共展示了matchers.LessThan方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_compression_is_worth_it

# 需要導入模塊: from testtools import matchers [as 別名]
# 或者: from testtools.matchers import LessThan [as 別名]
def test_compression_is_worth_it(self):
        argument = arguments.CompressedAmpList(
            [("ip", amp.Unicode()), ("mac", amp.Unicode())]
        )
        # Create 3500 leases. We can get up to ~3750 and still satisfy the
        # post-conditions, but the randomness means we can't be sure about
        # test stability that close to the limit.
        leases = [
            {
                "ip": factory.make_ipv4_address(),
                "mac": factory.make_mac_address(),
            }
            for _ in range(3500)
        ]
        encoded_compressed = argument.toStringProto(leases, proto=None)
        encoded_uncompressed = zlib.decompress(encoded_compressed)
        # The encoded leases compress to less than half the size of the
        # uncompressed leases, and under the AMP message limit of 64k.
        self.expectThat(
            len(encoded_compressed), LessThan(len(encoded_uncompressed) / 2)
        )
        self.expectThat(len(encoded_compressed), LessThan(2 ** 16)) 
開發者ID:maas,項目名稱:maas,代碼行數:24,代碼來源:test_arguments.py

示例2: test_ordering

# 需要導入模塊: from testtools import matchers [as 別名]
# 或者: from testtools.matchers import LessThan [as 別名]
def test_ordering(self):
        ordered_versions = [
            "1.2.3.dev6",
            "1.2.3.dev7",
            "1.2.3.a4.dev12",
            "1.2.3.a4.dev13",
            "1.2.3.a4",
            "1.2.3.a5.dev1",
            "1.2.3.a5",
            "1.2.3.b3.dev1",
            "1.2.3.b3",
            "1.2.3.rc2.dev1",
            "1.2.3.rc2",
            "1.2.3.rc3.dev1",
            "1.2.3",
            "1.2.4",
            "1.3.3",
            "2.2.3",
        ]
        for v in ordered_versions:
            sv = version.SemanticVersion.from_pip_string(v)
            self.expectThat(sv, matchers.Equals(sv))
        for left, right in itertools.combinations(ordered_versions, 2):
            l_pos = ordered_versions.index(left)
            r_pos = ordered_versions.index(right)
            if l_pos < r_pos:
                m1 = matchers.LessThan
                m2 = matchers.GreaterThan
            else:
                m1 = matchers.GreaterThan
                m2 = matchers.LessThan
            left_sv = version.SemanticVersion.from_pip_string(left)
            right_sv = version.SemanticVersion.from_pip_string(right)
            self.expectThat(left_sv, m1(right_sv))
            self.expectThat(right_sv, m2(left_sv)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:37,代碼來源:test_version.py

示例3: test_now

# 需要導入模塊: from testtools import matchers [as 別名]
# 或者: from testtools.matchers import LessThan [as 別名]
def test_now(self):
        self.assertIsInstance(self.eval('now()'), DT)
        self.assertIsInstance(self.eval('now(utctz())'), DT)
        self.assertIsInstance(self.eval('now(localtz())'), DT)
        self.assertThat(
            self.eval('now(utctz()) - now()'),
            matchers.LessThan(TS(seconds=1))
        )
        self.assertTrue(self.eval('now(localtz()).offset = localtz()')) 
開發者ID:openstack,項目名稱:yaql,代碼行數:11,代碼來源:test_datetime.py

示例4: test_datetime_math

# 需要導入模塊: from testtools import matchers [as 別名]
# 或者: from testtools.matchers import LessThan [as 別名]
def test_datetime_math(self):
        self.context['dt1'] = self.eval('now()')
        time.sleep(0.1)
        self.context['dt2'] = self.eval('now()')
        delta = TS(milliseconds=120)
        self.assertIsInstance(self.eval('$dt2 - $dt1'), TS)
        self.assertThat(self.eval('$dt2 - $dt1'), matchers.LessThan(delta))
        self.assertTrue(self.eval('($dt2 - $dt1) + $dt1 = $dt2'))
        self.assertTrue(self.eval('$dt1 + ($dt2 - $dt1) = $dt2'))
        self.assertThat(
            self.eval('($dt2 - $dt1) * 2'), matchers.LessThan(2 * delta))
        self.assertThat(
            self.eval('2.1 * ($dt2 - $dt1)'), matchers.LessThan(2 * delta))
        self.assertTrue(self.eval('-($dt1 - $dt2) = +($dt2 - $dt1)'))
        self.assertTrue(self.eval('$dt2 > $dt1'))
        self.assertTrue(self.eval('$dt2 >= $dt1'))
        self.assertTrue(self.eval('$dt2 != $dt1'))
        self.assertTrue(self.eval('$dt1 = $dt1'))
        self.assertTrue(self.eval('$dt1 < $dt2'))
        self.assertTrue(self.eval('$dt1 <= $dt2'))
        self.assertEqual(-1, self.eval('($dt2 - $dt1) / ($dt1 - $dt2)'))
        self.assertTrue(self.eval('$dt2 - ($dt2 - $dt1) = $dt1'))
        self.assertEqual(
            0, self.eval('($dt2 - $dt1) - ($dt2 - $dt1)').total_seconds())

        delta2 = self.eval('($dt2 - $dt1) / 2.1')
        self.assertThat(delta2, matchers.LessThan(delta / 2))
        self.assertTrue(self.eval('$dt1 + $ < $dt2', delta2))
        self.assertTrue(self.eval('$ + $dt1 < $dt2', delta2))
        self.assertTrue(self.eval('$dt2 - $dt1 > $', delta2))
        self.assertTrue(self.eval('$dt2 - $dt1 >= $', delta2))
        self.assertTrue(self.eval('$dt2 - $dt1 != $', delta2))
        self.assertFalse(self.eval('$dt2 - $dt1 < $', delta2))
        self.assertFalse(self.eval('$dt2 - $dt1 <= $', delta2))
        self.assertTrue(self.eval('($dt2 - $dt1) + $ > $', delta2)) 
開發者ID:openstack,項目名稱:yaql,代碼行數:37,代碼來源:test_datetime.py

示例5: test_set_time_override_using_default

# 需要導入模塊: from testtools import matchers [as 別名]
# 或者: from testtools.matchers import LessThan [as 別名]
def test_set_time_override_using_default(self):
        now = timeutils.utcnow_ts()

        # NOTE(kgriffs): Normally it's bad form to sleep in a unit test,
        # but this is the only way to test that set_time_override defaults
        # to setting the override to the current time.
        time.sleep(1)

        timeutils.set_time_override()
        overriden_now = timeutils.utcnow_ts()
        self.assertThat(now, matchers.LessThan(overriden_now)) 
開發者ID:openstack,項目名稱:oslo.utils,代碼行數:13,代碼來源:test_timeutils.py


注:本文中的testtools.matchers.LessThan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。