def test_target_platform(self): # Test that we can use target_platform in a recipe. We don't care about # the results here. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( """ package: name: foo_{{ target_platform }} version: 1.0 """ ) lints = linter.main(recipe_dir)
def test_unicode(self): """ Tests that unicode does not confuse the linter. """ with tmp_directory() as recipe_dir: with io.open( os.path.join(recipe_dir, "meta.yaml"), "wt", encoding="utf-8" ) as fh: fh.write( """ package: name: 'test_package' build: number: 0 about: home: something license: something else summary: αβɣ description: moɿɘ uniɔobɘ! """ ) # Just run it and make sure it does not raise. linter.main(recipe_dir)
def test_jinja_os_sep(self): # Test that we can use os.sep in a recipe. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( """ package: name: foo_ version: 1.0 build: script: {{ os.sep }} """ ) lints = linter.main(recipe_dir)
def test_jinja_os_environ(self): # Test that we can use os.environ in a recipe. We don't care about # the results here. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( """ {% set version = os.environ.get('WIBBLE') %} package: name: foo version: {{ version }} """ ) lints = linter.main(recipe_dir)
def assert_noarch_hint(meta_string, is_good=False): with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write(meta_string) lints, hints = linter.main(recipe_dir, return_hints=True) if is_good: message = ( "Found hints when there shouldn't have " "been a lint for '{}'." ).format(meta_string) else: message = ( "Expected hints for '{}', but didn't " "get any." ).format(meta_string) self.assertEqual( not is_good, any(lint.startswith(expected_start) for lint in hints), message, )
def test_jinja_load_file_regex(self): # Test that we can use load_file_regex in a recipe. We don't care about # the results here. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "sha256"), "w") as fh: fh.write( """ d0e46ea5fca7d4c077245fe0b4195a828d9d4d69be8a0bd46233b2c12abd2098 iwftc_osx.zip 8ce4dc535b21484f65027be56263d8b0d9f58e57532614e1a8f6881f3b8fe260 iwftc_win.zip """ ) with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( """ {% set sha256_osx = load_file_regex(load_file="sha256", regex_pattern="(?m)^(?P<sha256>[0-9a-f]+)\\s+iwftc_osx.zip$", from_recipe_dir=True)["sha256"] %} package: name: foo version: {{ version }} """ ) lints = linter.main(recipe_dir)
def test_multiple_sources(self): lints = linter.main(os.path.join(_thisdir, "recipes", "multiple_sources")) assert not lints
def test_cb3_jinja2_functions(self): lints = linter.main( os.path.join(_thisdir, "recipes", "cb3_jinja2_functions", "recipe") ) assert not lints