Skip to content

Commit

Permalink
use pytest.raises instead of nose.tools.raises (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeine committed Feb 20, 2022
1 parent 4d1d35a commit 16eba6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
5 changes: 2 additions & 3 deletions test/test_imread.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import qimage2ndarray, os, numpy

from nose.tools import raises
import pytest


Expand All @@ -10,11 +9,11 @@ def _locate_test_image(basename):
return result


@raises(IOError)
def test_imread_file_not_found():
filename = 'non_existing_image_file.png'

qimage2ndarray.imread(filename)
with pytest.raises(IOError):
qimage2ndarray.imread(filename)


def test_imread_box():
Expand Down
22 changes: 11 additions & 11 deletions test/test_qimageview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from qimage2ndarray.dynqt import qt, QtGui
import sys, numpy

from nose.tools import raises
from compat import setNumColors, numBytes
import pytest


def test_viewcreation():
Expand All @@ -17,18 +17,18 @@ def test_viewcreation():
assert (w, h) == (320, 240)
v[239] = numpy.arange(320) # should not segfault

@raises(TypeError)
def test_qimageview_noargs():
v = _qimageview()
with pytest.raises(TypeError):
v = _qimageview()

@raises(TypeError)
def test_qimageview_manyargs():
qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
v = _qimageview(qimg, 1)
with pytest.raises(TypeError):
v = _qimageview(qimg, 1)

@raises(TypeError)
def test_qimageview_wrongarg():
v = _qimageview(42)
with pytest.raises(TypeError):
v = _qimageview(42)

def test_data_access():
qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
Expand Down Expand Up @@ -150,12 +150,12 @@ def test_odd_size_32bit_rgb():
assert v.strides[0] == qimg.bytesPerLine()
assert v.strides[1] == 4

@raises(ValueError)
def test_mono():
qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Mono)
v = _qimageview(qimg)
with pytest.raises(ValueError):
v = _qimageview(qimg)

@raises(ValueError)
def test_rgb666():
qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB666)
v = _qimageview(qimg)
with pytest.raises(ValueError):
v = _qimageview(qimg)

0 comments on commit 16eba6e

Please sign in to comment.