-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check that object is done initialized before calling bound functions
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
six | ||
pytest |
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,29 @@ | ||
from cwrap import BaseCClass, Prototype, load | ||
import os | ||
import pytest | ||
|
||
|
||
class LibCPrototype(Prototype): | ||
lib = load("msvcrt" if os.name == "nt" else None) | ||
|
||
def __init__(self, prototype, bind): | ||
super(LibCPrototype, self).__init__( | ||
LibCPrototype.lib, | ||
prototype, | ||
bind=bind) | ||
|
||
|
||
class BadInitialization(BaseCClass): | ||
TYPE_NAME = "bad_initialization" | ||
_abs = LibCPrototype("int abs(int)", bind=True) | ||
|
||
def __init__(self): | ||
self._abs(0) # called before initialization, should raise | ||
|
||
def free(self): | ||
pass | ||
|
||
|
||
def test_that_unitialized_is_raised(): | ||
with pytest.raises(ValueError, match="uninitialized"): | ||
_ = BadInitialization() |