Skip to content

Commit

Permalink
Use pytest directly, as going via py does no longer work
Browse files Browse the repository at this point in the history
Starting with pytest 7.2.0(?) py.test.raises only works if py is also
installed. Given pytest-dev/py#288 it is
probably easiest to just use pytest directly if possible
  • Loading branch information
tmadlener committed Dec 7, 2022
1 parent 8b273b0 commit 022cc4d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ilcsoft/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
################################################

from .version import Version
import py
import pytest

def test_sanity():
py.test.raises(TypeError, Version )
py.test.raises(ValueError, Version, 0)
py.test.raises(ValueError, Version, [])
py.test.raises(ValueError, Version, '')
py.test.raises(ValueError, Version, '1')
py.test.raises(ValueError, Version, '1.')
py.test.raises(ValueError, Version, 'a.b')
py.test.raises(ValueError, Version, 'blah')
pytest.raises(TypeError, Version )
pytest.raises(ValueError, Version, 0)
pytest.raises(ValueError, Version, [])
pytest.raises(ValueError, Version, '')
pytest.raises(ValueError, Version, '1')
pytest.raises(ValueError, Version, '1.')
pytest.raises(ValueError, Version, 'a.b')
pytest.raises(ValueError, Version, 'blah')

def test_general():

MIN_ELEM = Version._min_elements

# versions must have at least one element > 0
py.test.raises(ValueError, Version, MIN_ELEM * (0,) )
pytest.raises(ValueError, Version, MIN_ELEM * (0,) )

# elements must be integers or convertible to int
py.test.raises(ValueError, Version, (MIN_ELEM * [1]) + ['a'] )
pytest.raises(ValueError, Version, (MIN_ELEM * [1]) + ['a'] )

# elements must be >= 0
py.test.raises(ValueError, Version, (MIN_ELEM * [1]) + [-1] )
pytest.raises(ValueError, Version, (MIN_ELEM * [1]) + [-1] )

# cutting off / filling missing elements
MAX_ELEM = 4
Expand Down

0 comments on commit 022cc4d

Please sign in to comment.