Adding recipe tests

Hello, I built a recipe using the pypi package and want to use the github source tests to test the package. I copy-pasted the tests in the recipe, but a reviewer is advising to use a second source but the recipe then fails when i try:

  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ pypi_name }}-{{ version }}.tar.gz
  sha256: {{ sha256 }}
  git_url: https://github.com/xxx/xxx/tests
  folder: tests

How to proceed?
Thank you

You need a list to have two sources:

  - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ pypi_name }}-{{ version }}.tar.gz
    sha256: {{ sha256 }}
  - git_url: https://github.com/xxx/xxx/tests
    folder: tests

Notice the dashes!

Thanks. I did try that as well, but then in the test section when I try to do:

test
  source_files:
    - tests/

It says the file can’t be found. Also, it assumes that it is a git repo, so I don’t think I can’t download just the tests directory

My solution:
run a git checkout for just the test directory (I tried a svn, but somehow even though svn is a defaults conda package, it can’t find it):

  commands:
    - git clone --depth 1 --no-checkout --filter=tree:0 https://github.com/robotics-4-all/{{ name }}
    - cd commlib-py
    - git config core.protectNTFS false  # [win]
    - git sparse-checkout set --no-cone tests
    - git checkout
    - coverage run -m unittest discover

Will it be accepted?

I would then try to download a github tarball with the whole thing (via url and sha256), extract it to a different folder via folder (e.g. github_repo), and then have test.files point to {{SRC_DIR}}/github_repo/tests. That should work I think?

...
sources:
  - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ pypi_name }}-{{ version }}.tar.gz
    sha256: {{ sha256 }}
  - git_url: https://github.com/xxx/xxx/archive/{{version}}.tar.gz
    sha256: xxxxxx
    folder: gh_repo
...

tests:
  source_files:
    - gh_repo/tests

I understand the desire to do this, but it may not be the best way to go (and it is a pain, as you know!)

In theory, tests in conda build only need to test that the package built correctly, not that the code itself works. For many (most?) packages, if it imports, they you are good to go. (e.g. the dependencies are all there).

For a somewhat more complex package that may have optional imports, or ??, ideally, there would be small set of tests installed with the package that are just enough to know it installed properly.

If you have control of the upstream package, I’d consider doing that. If not, maybe a PR is in order?

Otherwise, once you find a working solution, then please to post here – this has been a challenge for a long time.