Skip to content

Commit

Permalink
add test with python_requires options values example (#13487)
Browse files Browse the repository at this point in the history
Changelog: Fix: Define a way to update ``default_options`` in
``python_requires_extend`` extension.
Docs: conan-io/docs#3120

Close #13486
  • Loading branch information
AbrilRBS authored Mar 22, 2023
2 parents 7fdcf39 + b2b3408 commit 9ca63fe
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions conans/test/integration/py_requires/python_requires_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,44 @@ def build_id(self):
self.assertIn("pkg/0.1@user/testing: My cool package!", client.out)
self.assertIn("pkg/0.1@user/testing: My cool package_info!", client.out)

def test_options_errors(self):
c = TestClient()
base = textwrap.dedent("""
from conan import ConanFile
class BaseConan:
options = {"base": [True, False]}
default_options = {"base": True}
class PyReq(ConanFile):
name = "base"
version = "1.0.0"
package_type = "python-require"
""")
derived = textwrap.dedent("""
import conan
class DerivedConan(conan.ConanFile):
name = "derived"
python_requires = "base/1.0.0"
python_requires_extend = "base.BaseConan"
options = {"derived": [True, False]}
default_options = {"derived": False}
def init(self):
base = self.python_requires["base"].module.BaseConan
self.options.update(base.options, base.default_options)
def generate(self):
self.output.info(f"OptionBASE: {self.options.base}")
self.output.info(f"OptionDERIVED: {self.options.derived}")
""")
c.save({"base/conanfile.py": base,
"derived/conanfile.py": derived})
c.run("create base")
c.run("install derived")
assert "OptionBASE: True" in c.out
assert "OptionDERIVED: False" in c.out


def test_transitive_python_requires():
# https://github.com/conan-io/conan/issues/8546
Expand Down

0 comments on commit 9ca63fe

Please sign in to comment.