|
4 | 4 | See https://github.com/pytest-dev/pytest/issues/3333 for details.
|
5 | 5 |
|
6 | 6 | """
|
7 |
| -import sys |
8 |
| - |
9 | 7 | import pytest
|
10 | 8 | from _pytest.pytester import Pytester
|
11 | 9 |
|
@@ -210,68 +208,63 @@ def test_this():
|
210 | 208 | """,
|
211 | 209 | id='Test "not in" string',
|
212 | 210 | ),
|
213 |
| -] |
214 |
| -if sys.version_info[:2] >= (3, 7): |
215 |
| - TESTCASES.extend( |
216 |
| - [ |
217 |
| - pytest.param( |
218 |
| - """ |
219 |
| - from dataclasses import dataclass |
| 211 | + pytest.param( |
| 212 | + """ |
| 213 | + from dataclasses import dataclass |
220 | 214 |
|
221 |
| - @dataclass |
222 |
| - class A: |
223 |
| - a: int |
224 |
| - b: str |
| 215 | + @dataclass |
| 216 | + class A: |
| 217 | + a: int |
| 218 | + b: str |
225 | 219 |
|
226 |
| - def test_this(): |
227 |
| - result = A(1, 'spam') |
228 |
| - expected = A(2, 'spam') |
229 |
| - assert result == expected |
230 |
| - """, |
231 |
| - """ |
232 |
| - > assert result == expected |
233 |
| - E AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam') |
234 |
| - E Matching attributes: |
235 |
| - E ['b'] |
236 |
| - E Differing attributes: |
237 |
| - E ['a'] |
238 |
| - E Drill down into differing attribute a: |
239 |
| - E a: 1 != 2 |
240 |
| - E +1 |
241 |
| - E -2 |
242 |
| - """, |
243 |
| - id="Compare data classes", |
244 |
| - ), |
245 |
| - pytest.param( |
246 |
| - """ |
247 |
| - import attr |
| 220 | + def test_this(): |
| 221 | + result = A(1, 'spam') |
| 222 | + expected = A(2, 'spam') |
| 223 | + assert result == expected |
| 224 | + """, |
| 225 | + """ |
| 226 | + > assert result == expected |
| 227 | + E AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam') |
| 228 | + E Matching attributes: |
| 229 | + E ['b'] |
| 230 | + E Differing attributes: |
| 231 | + E ['a'] |
| 232 | + E Drill down into differing attribute a: |
| 233 | + E a: 1 != 2 |
| 234 | + E +1 |
| 235 | + E -2 |
| 236 | + """, |
| 237 | + id="Compare data classes", |
| 238 | + ), |
| 239 | + pytest.param( |
| 240 | + """ |
| 241 | + import attr |
248 | 242 |
|
249 |
| - @attr.s(auto_attribs=True) |
250 |
| - class A: |
251 |
| - a: int |
252 |
| - b: str |
| 243 | + @attr.s(auto_attribs=True) |
| 244 | + class A: |
| 245 | + a: int |
| 246 | + b: str |
253 | 247 |
|
254 |
| - def test_this(): |
255 |
| - result = A(1, 'spam') |
256 |
| - expected = A(1, 'eggs') |
257 |
| - assert result == expected |
258 |
| - """, |
259 |
| - """ |
260 |
| - > assert result == expected |
261 |
| - E AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs') |
262 |
| - E Matching attributes: |
263 |
| - E ['a'] |
264 |
| - E Differing attributes: |
265 |
| - E ['b'] |
266 |
| - E Drill down into differing attribute b: |
267 |
| - E b: 'spam' != 'eggs' |
268 |
| - E - eggs |
269 |
| - E + spam |
270 |
| - """, |
271 |
| - id="Compare attrs classes", |
272 |
| - ), |
273 |
| - ] |
274 |
| - ) |
| 248 | + def test_this(): |
| 249 | + result = A(1, 'spam') |
| 250 | + expected = A(1, 'eggs') |
| 251 | + assert result == expected |
| 252 | + """, |
| 253 | + """ |
| 254 | + > assert result == expected |
| 255 | + E AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs') |
| 256 | + E Matching attributes: |
| 257 | + E ['a'] |
| 258 | + E Differing attributes: |
| 259 | + E ['b'] |
| 260 | + E Drill down into differing attribute b: |
| 261 | + E b: 'spam' != 'eggs' |
| 262 | + E - eggs |
| 263 | + E + spam |
| 264 | + """, |
| 265 | + id="Compare attrs classes", |
| 266 | + ), |
| 267 | +] |
275 | 268 |
|
276 | 269 |
|
277 | 270 | @pytest.mark.parametrize("code, expected", TESTCASES)
|
|
0 commit comments