Skip to content

Commit 2684987

Browse files
njsmithines
authored andcommitted
When calling getoption() in conftest.py, pass a default option (#2709)
* When calling getoption() in conftest.py, pass a default option This is necessary to allow testing an installed spacy by running: pytest --pyargs spacy * Add contributor agreement
1 parent e9022f7 commit 2684987

File tree

2 files changed

+117
-2
lines changed

2 files changed

+117
-2
lines changed

.github/contributors/njsmith.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# spaCy contributor agreement
2+
3+
This spaCy Contributor Agreement (**"SCA"**) is based on the
4+
[Oracle Contributor Agreement](http://www.oracle.com/technetwork/oca-405177.pdf).
5+
The SCA applies to any contribution that you make to any product or project
6+
managed by us (the **"project"**), and sets out the intellectual property rights
7+
you grant to us in the contributed materials. The term **"us"** shall mean
8+
[ExplosionAI UG (haftungsbeschränkt)](https://explosion.ai/legal). The term
9+
**"you"** shall mean the person or entity identified below.
10+
11+
If you agree to be bound by these terms, fill in the information requested
12+
below and include the filled-in version with your first pull request, under the
13+
folder [`.github/contributors/`](/.github/contributors/). The name of the file
14+
should be your GitHub username, with the extension `.md`. For example, the user
15+
example_user would create the file `.github/contributors/example_user.md`.
16+
17+
Read this agreement carefully before signing. These terms and conditions
18+
constitute a binding legal agreement.
19+
20+
## Contributor Agreement
21+
22+
1. The term "contribution" or "contributed materials" means any source code,
23+
object code, patch, tool, sample, graphic, specification, manual,
24+
documentation, or any other material posted or submitted by you to the project.
25+
26+
2. With respect to any worldwide copyrights, or copyright applications and
27+
registrations, in your contribution:
28+
29+
* you hereby assign to us joint ownership, and to the extent that such
30+
assignment is or becomes invalid, ineffective or unenforceable, you hereby
31+
grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge,
32+
royalty-free, unrestricted license to exercise all rights under those
33+
copyrights. This includes, at our option, the right to sublicense these same
34+
rights to third parties through multiple levels of sublicensees or other
35+
licensing arrangements;
36+
37+
* you agree that each of us can do all things in relation to your
38+
contribution as if each of us were the sole owners, and if one of us makes
39+
a derivative work of your contribution, the one who makes the derivative
40+
work (or has it made will be the sole owner of that derivative work;
41+
42+
* you agree that you will not assert any moral rights in your contribution
43+
against us, our licensees or transferees;
44+
45+
* you agree that we may register a copyright in your contribution and
46+
exercise all ownership rights associated with it; and
47+
48+
* you agree that neither of us has any duty to consult with, obtain the
49+
consent of, pay or render an accounting to the other for any use or
50+
distribution of your contribution.
51+
52+
3. With respect to any patents you own, or that you can license without payment
53+
to any third party, you hereby grant to us a perpetual, irrevocable,
54+
non-exclusive, worldwide, no-charge, royalty-free license to:
55+
56+
* make, have made, use, sell, offer to sell, import, and otherwise transfer
57+
your contribution in whole or in part, alone or in combination with or
58+
included in any product, work or materials arising out of the project to
59+
which your contribution was submitted, and
60+
61+
* at our option, to sublicense these same rights to third parties through
62+
multiple levels of sublicensees or other licensing arrangements.
63+
64+
4. Except as set out above, you keep all right, title, and interest in your
65+
contribution. The rights that you grant to us under these terms are effective
66+
on the date you first submitted a contribution to us, even if your submission
67+
took place before the date you sign these terms.
68+
69+
5. You covenant, represent, warrant and agree that:
70+
71+
* Each contribution that you submit is and shall be an original work of
72+
authorship and you can legally grant the rights set out in this SCA;
73+
74+
* to the best of your knowledge, each contribution will not violate any
75+
third party's copyrights, trademarks, patents, or other intellectual
76+
property rights; and
77+
78+
* each contribution shall be in compliance with U.S. export control laws and
79+
other applicable export and import laws. You agree to notify us if you
80+
become aware of any circumstance which would make any of the foregoing
81+
representations inaccurate in any respect. We may publicly disclose your
82+
participation in the project, including the fact that you have signed the SCA.
83+
84+
6. This SCA is governed by the laws of the State of California and applicable
85+
U.S. Federal law. Any choice of law rules will not apply.
86+
87+
7. Please place an “x” on one of the applicable statement below. Please do NOT
88+
mark both statements:
89+
90+
* [x] I am signing on behalf of myself as an individual and no other person
91+
or entity, including my employer, has or will have rights with respect to my
92+
contributions.
93+
94+
* [ ] I am signing on behalf of my employer or a legal entity and I have the
95+
actual authority to contractually bind that entity.
96+
97+
## Contributor Details
98+
99+
| Field | Entry |
100+
|------------------------------- | -------------------- |
101+
| Name | Nathaniel J. Smith |
102+
| Company name (if applicable) | |
103+
| Title or role (if applicable) | |
104+
| Date | 2018-08-26 |
105+
| GitHub username | njsmith |
106+
| Website (optional) | https://vorpus.org |

spacy/tests/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,22 @@ def pytest_addoption(parser):
212212

213213

214214
def pytest_runtest_setup(item):
215+
def getopt(opt):
216+
# When using 'pytest --pyargs spacy' to test an installed copy of
217+
# spacy, pytest skips running our pytest_addoption() hook. Later, when
218+
# we call getoption(), pytest raises an error, because it doesn't
219+
# recognize the option we're asking about. To avoid this, we need to
220+
# pass a default value. We default to False, i.e., we act like all the
221+
# options weren't given.
222+
return item.config.getoption("--%s" % opt, False)
223+
215224
for opt in ['models', 'vectors', 'slow']:
216-
if opt in item.keywords and not item.config.getoption("--%s" % opt):
225+
if opt in item.keywords and not getopt(opt):
217226
pytest.skip("need --%s option to run" % opt)
218227

219228
# Check if test is marked with models and has arguments set, i.e. specific
220229
# language. If so, skip test if flag not set.
221230
if item.get_marker('models'):
222231
for arg in item.get_marker('models').args:
223-
if not item.config.getoption("--%s" % arg) and not item.config.getoption("--all"):
232+
if not getopt(arg) and not getopt("all"):
224233
pytest.skip("need --%s or --all option to run" % arg)

0 commit comments

Comments
 (0)