def test_to_string_colon_format_with_hardness(self): self.assertEqual( 'all: RUN foo >= 1.2.3', R('foo', '>=', '1.2.3', None, 'RUN').to_string_colon_format()) self.assertEqual( 'linux: TOOL foo >= 1.2.3', R('foo', '>=', '1.2.3', 'linux', 'TOOL').to_string_colon_format())
def test_hardness_matches(self): self.assertTrue( R('foo', '>=', '1.2.3', 'linux', 'RUN').hardness_matches('RUN')) self.assertFalse( R('foo', '>=', '1.2.3', 'linux', 'RUN').hardness_matches('TOOL')) self.assertTrue( R('foo', '>=', '1.2.3', 'linux', None).hardness_matches('RUN'))
def test_to_string_colon_format(self): self.assertEqual( 'all: foo >= 1.2.3', R('foo', '>=', '1.2.3', None).to_string_colon_format()) self.assertEqual( 'linux: foo >= 1.2.3', R('foo', '>=', '1.2.3', 'linux').to_string_colon_format())
def test_hardness_matches_seq(self): self.assertTrue( R('foo', '>=', '1.2.3', 'linux', 'RUN').hardness_matches(['RUN', 'TOOL'])) self.assertTrue( R('foo', '>=', '1.2.3', 'linux', 'TOOL').hardness_matches(['RUN', 'TOOL'])) self.assertTrue( R('foo', '>=', '1.2.3', 'linux', None).hardness_matches(['RUN', 'TOOL']))
def test_system_mask_matches(self): self.assertTrue( R('foo', '>=', '1.2.3', 'linux', None).system_mask_matches('linux')) self.assertFalse( R('foo', '>=', '1.2.3', 'linux', None).system_mask_matches('macos')) self.assertTrue( R('foo', '>=', '1.2.3', 'all', None).system_mask_matches('linux')) self.assertTrue( R('foo', '>=', '1.2.3', 'all', None).system_mask_matches('macos'))
def test___str__(self): self.assertEqual('foo >= 1.2.3', str(R('foo', '>=', '1.2.3'))) self.assertEqual('orange >= 6.6.6', str(R('orange', '>=', '6.6.6')))
def test_clone_replace_system_mask(self): r1 = R('foo', '>=', '1.2.3', 'linux', 'RUN') r2 = r1.clone_replace_system_mask('macos') self.assertEqual('linux', str(r1.system_mask)) self.assertEqual('macos', str(r2.system_mask))
def test_clone_replace_hardness(self): r1 = R('foo', '>=', '1.2.3', 'linux', 'RUN') r2 = r1.clone_replace_hardness('BUILD') self.assertEqual('RUN', str(r1.hardness)) self.assertEqual('BUILD', str(r2.hardness))
def test___str__with_hardness(self): self.assertEqual('RUN foo(linux) >= 1.2.3', str(R('foo', '>=', '1.2.3', 'linux', 'RUN')))
def test___str__with_system(self): self.assertEqual('foo(linux) >= 1.2.3', str(R('foo', '>=', '1.2.3', 'linux'))) self.assertEqual('orange >= 6.6.6', str(R('orange', '>=', '6.6.6', 'all')))
def test_to_string_with_system(self): reqs = RL([ R('foo', '>=', '1.2.3', 'macos'), R('orange', '>=', '6.6.6', 'all'), R('bar', None, None, 'desktop'), R('baz', None, None, 'linux') ]) self.assertEqual( 'foo(macos) >= 1.2.3 orange >= 6.6.6 bar(desktop) baz(linux)', str(reqs) )
def test_to_string(self): reqs = RL([ R('foo', '>=', '1.2.3'), R('orange', '>=', '6.6.6'), R('bar', None, None), R('baz', None, None) ]) self.assertEqual( 'foo >= 1.2.3 orange >= 6.6.6 bar baz', str(reqs) )