Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
382db5b2
Commit
382db5b2
authored
Aug 13, 2016
by
Dean Moldovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move inheritance tests into the proper file
parent
665e8804
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
26 deletions
+27
-26
tests/test_callbacks.py
+0
-26
tests/test_inheritance.py
+27
-0
No files found.
tests/test_callbacks.py
View file @
382db5b2
import
pytest
import
pytest
def
test_inheritance
(
msg
):
from
pybind11_tests
import
Pet
,
Dog
,
Rabbit
,
dog_bark
,
pet_name_species
roger
=
Rabbit
(
'Rabbit'
)
assert
roger
.
name
()
+
" is a "
+
roger
.
species
()
==
"Rabbit is a parrot"
assert
pet_name_species
(
roger
)
==
"Rabbit is a parrot"
polly
=
Pet
(
'Polly'
,
'parrot'
)
assert
polly
.
name
()
+
" is a "
+
polly
.
species
()
==
"Polly is a parrot"
assert
pet_name_species
(
polly
)
==
"Polly is a parrot"
molly
=
Dog
(
'Molly'
)
assert
molly
.
name
()
+
" is a "
+
molly
.
species
()
==
"Molly is a dog"
assert
pet_name_species
(
molly
)
==
"Molly is a dog"
assert
dog_bark
(
molly
)
==
"Woof!"
with
pytest
.
raises
(
TypeError
)
as
excinfo
:
dog_bark
(
polly
)
assert
msg
(
excinfo
.
value
)
==
"""
Incompatible function arguments. The following argument types are supported:
1. (arg0: m.Dog) -> str
Invoked with: <m.Pet object at 0>
"""
def
test_callbacks
():
def
test_callbacks
():
from
functools
import
partial
from
functools
import
partial
from
pybind11_tests
import
(
test_callback1
,
test_callback2
,
test_callback3
,
from
pybind11_tests
import
(
test_callback1
,
test_callback2
,
test_callback3
,
...
...
tests/test_inheritance.py
View file @
382db5b2
import
pytest
def
test_inheritance
(
msg
):
from
pybind11_tests
import
Pet
,
Dog
,
Rabbit
,
dog_bark
,
pet_name_species
roger
=
Rabbit
(
'Rabbit'
)
assert
roger
.
name
()
+
" is a "
+
roger
.
species
()
==
"Rabbit is a parrot"
assert
pet_name_species
(
roger
)
==
"Rabbit is a parrot"
polly
=
Pet
(
'Polly'
,
'parrot'
)
assert
polly
.
name
()
+
" is a "
+
polly
.
species
()
==
"Polly is a parrot"
assert
pet_name_species
(
polly
)
==
"Polly is a parrot"
molly
=
Dog
(
'Molly'
)
assert
molly
.
name
()
+
" is a "
+
molly
.
species
()
==
"Molly is a dog"
assert
pet_name_species
(
molly
)
==
"Molly is a dog"
assert
dog_bark
(
molly
)
==
"Woof!"
with
pytest
.
raises
(
TypeError
)
as
excinfo
:
dog_bark
(
polly
)
assert
msg
(
excinfo
.
value
)
==
"""
Incompatible function arguments. The following argument types are supported:
1. (arg0: m.Dog) -> str
Invoked with: <m.Pet object at 0>
"""
def
test_automatic_upcasting
():
def
test_automatic_upcasting
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment