|
3 | 3 | # |
4 | 4 | # SPDX-License-Identifier: BSD-3-Clause |
5 | 5 |
|
| 6 | +import pytest |
6 | 7 | import unittest |
7 | 8 |
|
8 | 9 | import reframe.core.runtime as rt |
@@ -47,67 +48,56 @@ def count_checks(self, filter_fn): |
47 | 48 | return sn.count(filter(filter_fn, self.checks)) |
48 | 49 |
|
49 | 50 | def test_have_name(self): |
50 | | - self.assertEqual(1, self.count_checks(filters.have_name('check1'))) |
51 | | - self.assertEqual(3, self.count_checks(filters.have_name('check'))) |
52 | | - self.assertEqual(2, self.count_checks(filters.have_name(r'\S*1|\S*3'))) |
53 | | - self.assertEqual(0, self.count_checks(filters.have_name('Check'))) |
54 | | - self.assertEqual(3, self.count_checks(filters.have_name('(?i)Check'))) |
55 | | - self.assertEqual( |
56 | | - 2, self.count_checks(filters.have_name('(?i)check1|CHECK2')) |
57 | | - ) |
| 51 | + assert 1 == self.count_checks(filters.have_name('check1')) |
| 52 | + assert 3 == self.count_checks(filters.have_name('check')) |
| 53 | + assert 2 == self.count_checks(filters.have_name(r'\S*1|\S*3')) |
| 54 | + assert 0 == self.count_checks(filters.have_name('Check')) |
| 55 | + assert 3 == self.count_checks(filters.have_name('(?i)Check')) |
| 56 | + assert 2 == self.count_checks(filters.have_name('(?i)check1|CHECK2')) |
58 | 57 |
|
59 | 58 | def test_have_not_name(self): |
60 | | - self.assertEqual(2, self.count_checks(filters.have_not_name('check1'))) |
61 | | - self.assertEqual( |
62 | | - 1, self.count_checks(filters.have_not_name('check1|check3')) |
63 | | - ) |
64 | | - self.assertEqual( |
65 | | - 0, self.count_checks(filters.have_not_name('check1|check2|check3')) |
66 | | - ) |
67 | | - self.assertEqual(3, self.count_checks(filters.have_not_name('Check1'))) |
68 | | - self.assertEqual( |
69 | | - 2, self.count_checks(filters.have_not_name('(?i)Check1')) |
70 | | - ) |
| 59 | + assert 2 == self.count_checks(filters.have_not_name('check1')) |
| 60 | + assert 1 == self.count_checks(filters.have_not_name('check1|check3')) |
| 61 | + assert 0 == self.count_checks(filters.have_not_name( |
| 62 | + 'check1|check2|check3')) |
| 63 | + assert 3 == self.count_checks(filters.have_not_name('Check1')) |
| 64 | + assert 2 == self.count_checks(filters.have_not_name('(?i)Check1')) |
71 | 65 |
|
72 | 66 | def test_have_tags(self): |
73 | | - self.assertEqual(2, self.count_checks(filters.have_tag('a|c'))) |
74 | | - self.assertEqual(0, self.count_checks(filters.have_tag('p|q'))) |
75 | | - self.assertEqual(2, self.count_checks(filters.have_tag('z'))) |
| 67 | + assert 2 == self.count_checks(filters.have_tag('a|c')) |
| 68 | + assert 0 == self.count_checks(filters.have_tag('p|q')) |
| 69 | + assert 2 == self.count_checks(filters.have_tag('z')) |
76 | 70 |
|
77 | 71 | def test_have_prgenv(self): |
78 | | - self.assertEqual( |
79 | | - 1, self.count_checks(filters.have_prgenv('env1|env2')) |
80 | | - ) |
81 | | - self.assertEqual(2, self.count_checks(filters.have_prgenv('env3'))) |
82 | | - self.assertEqual(1, self.count_checks(filters.have_prgenv('env4'))) |
83 | | - self.assertEqual( |
84 | | - 3, self.count_checks(filters.have_prgenv('env1|env3')) |
85 | | - ) |
| 72 | + assert 1 == self.count_checks(filters.have_prgenv('env1|env2')) |
| 73 | + assert 2 == self.count_checks(filters.have_prgenv('env3')) |
| 74 | + assert 1 == self.count_checks(filters.have_prgenv('env4')) |
| 75 | + assert 3 == self.count_checks(filters.have_prgenv('env1|env3')) |
86 | 76 |
|
87 | 77 | @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') |
88 | 78 | def test_partition(self): |
89 | 79 | p = rt.runtime().system.partition('gpu') |
90 | | - self.assertEqual(2, self.count_checks(filters.have_partition([p]))) |
| 80 | + assert 2 == self.count_checks(filters.have_partition([p])) |
91 | 81 | p = rt.runtime().system.partition('login') |
92 | | - self.assertEqual(0, self.count_checks(filters.have_partition([p]))) |
| 82 | + assert 0 == self.count_checks(filters.have_partition([p])) |
93 | 83 |
|
94 | 84 | def test_have_gpu_only(self): |
95 | | - self.assertEqual(2, self.count_checks(filters.have_gpu_only())) |
| 85 | + assert 2 == self.count_checks(filters.have_gpu_only()) |
96 | 86 |
|
97 | 87 | def test_have_cpu_only(self): |
98 | | - self.assertEqual(1, self.count_checks(filters.have_cpu_only())) |
| 88 | + assert 1 == self.count_checks(filters.have_cpu_only()) |
99 | 89 |
|
100 | 90 | def test_invalid_regex(self): |
101 | 91 | # We need to explicitly call `evaluate` to make sure the exception |
102 | 92 | # is triggered in all cases |
103 | | - with self.assertRaises(ReframeError): |
| 93 | + with pytest.raises(ReframeError): |
104 | 94 | self.count_checks(filters.have_name('*foo')).evaluate() |
105 | 95 |
|
106 | | - with self.assertRaises(ReframeError): |
| 96 | + with pytest.raises(ReframeError): |
107 | 97 | self.count_checks(filters.have_not_name('*foo')).evaluate() |
108 | 98 |
|
109 | | - with self.assertRaises(ReframeError): |
| 99 | + with pytest.raises(ReframeError): |
110 | 100 | self.count_checks(filters.have_tag('*foo')).evaluate() |
111 | 101 |
|
112 | | - with self.assertRaises(ReframeError): |
| 102 | + with pytest.raises(ReframeError): |
113 | 103 | self.count_checks(filters.have_prgenv('*foo')).evaluate() |
0 commit comments