This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
191 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +0,0 @@ | ||
import libraw.bindings | ||
|
||
libraw = libraw.bindings.libraw | ||
""" | ||
A handle to the LibRaw binary installed on the end users machine. | ||
This should always be imported first by anything that wants to use `libraw`: | ||
.. sourcecode:: python | ||
from libraw import libraw | ||
""" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import mock | ||
import pytest | ||
|
||
from libraw.bindings import LibRaw | ||
|
||
|
||
@pytest.fixture | ||
def libraw(): | ||
return LibRaw() | ||
|
||
|
||
def test_libraw_sets_method_name(libraw): | ||
""" | ||
Ensure that the method name is set when calling a LibRaw function. | ||
""" | ||
|
||
libraw._FuncPtr = mock.Mock() | ||
libraw.libraw_init() | ||
|
||
assert libraw.libraw_init.__name__ == 'libraw_init' | ||
|
||
|
||
def test_error_checking(libraw): | ||
""" | ||
Check that libraw methods are assigned an error checker (unless they're on | ||
the white list). | ||
""" | ||
|
||
libraw._FuncPtr = mock.Mock() | ||
|
||
libraw.libraw_cameraCount() | ||
assert libraw.libraw_cameraCount.errcheck != LibRaw.check_call | ||
|
||
libraw.libraw_something() | ||
assert libraw.libraw_something.errcheck == LibRaw.check_call | ||
|
||
|
||
def test_version_number_calculation(libraw): | ||
""" | ||
Check that the version tuple is calculated correctly. | ||
""" | ||
|
||
libraw.libraw_versionNumber = lambda: 4097 | ||
assert libraw.version_number == (0, 16, 1) | ||
|
||
|
||
def test_version(libraw): | ||
""" | ||
Check that the version method actually calls `LibRaw::version()`. | ||
""" | ||
|
||
libraw.libraw_version = mock.Mock() | ||
libraw.version | ||
libraw.libraw_version.assert_called_once_with() | ||
|
||
|
||
def test_get_non_libraw_method(libraw): | ||
""" | ||
Tets getting a method from an instance of `LibRaw` that does not exist in | ||
the DLL (eg. that does not start with `libraw_`) and is not an instance | ||
method. Expected behavior is to return `None`. | ||
""" | ||
|
||
assert libraw.test is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import pytest | ||
|
||
from libraw.errors import check_call | ||
from libraw.bindings import LibRaw | ||
from libraw.errors import UnspecifiedError | ||
|
||
|
||
def test_check_call_success(): | ||
check_call(0) | ||
LibRaw.check_call(0, None, None) | ||
|
||
|
||
def test_check_call_error(): | ||
with pytest.raises(UnspecifiedError): | ||
check_call(-1) | ||
LibRaw.check_call(-1, None, None) |
Oops, something went wrong.