Inna córka

twojacena.pl 17 godzin temu

Ojciec Jagody był starszy od mamy o piętnaście lat. Ubierał się schludnie, choćby nieco staroświecko. Zawsze nosił spodnie, koszulę, marynarkę lub sweter. Żadnych adidasów ani t-shirtów. W ogóle nie przypominał ojców jej koleżanek. Jagoda go uwielbiała. Gdy wracał z pracy, biegła mu na spotkanie, a on łapał ją w ramiona i patrząc w oczy, pytał:

*Jak minął dzień mojej księżniczki?*

Jagodzie bardzo się podobało, gdy tak ją nazywał. Przytulała go, wdychając ten wyjątkowy zapach – najlepszy na świecie, zapach szczęścia: mieszankę wody kolońskiej, papierosów i czegoś jeszcze, czego nie potrafiła nazwać.

*A ja nie jestem księżniczką?* – pytała mama, nadąsana, czekając na swoją porcTitle: Use `conda-forge` and `default` for testing `local` with conda
username_0: In #14, `conda-forge` is added to the default list of `channel_priority` when `local` is set to `True`. However, when testing locally, only `conda-forge` was used, e.g., `pytest_local.py::test_conda_install_deps`. I think we should also test `default` channel with `local=True` so we can make sure that `channel_priority` is working. The testing could be done by adding an `if` condition to the `CONDA_INSTALL_DEPS` test and create a `pytest` fixture. However, I’m not sure what is the best approach to implement `pytest` fixture.

@username_1 would you be able to help on this? Thanks!
username_1: Hi @username_0!

I think the easiest way to do this is to make a second test for `test_conda_install_deps` with `local = True`, `channel_priority = „default”`. Alternatively, as you suggested, you could add a `pytest.mark.parametrize()` for `channel_priority` in the `test_conda_install_deps` test. Or, if you want to keep the local tests separate in the `pytest_locals.py` script, you can write a separate test function called `test_conda_install_deps_default` with `conda_local = True` and `channel_priority = „default”`.

Let me know what you think or if you were thinking of a different solution! Happy to help.
username_0: What I had in mind was to write a `pytest` fixture for the `CONDA_INSTALL_DEPS` test since we’ve already done so for `KNOWN_PIP_INSTALL_DEPS`. Would this work?

Would you be able to provide an example for implementing `pytest.mark.parametrize()` for this case? Thanks!
username_1: Oh, I see! You’re absolutely right that we should test both possible behaviours of `channel_priority` given that we’re making a major change by including `conda-forge` as a major channel. In that case, yes, the test should have `conda_local = True` and `channel_priority` should be either `default` or `conda-forge`.

Fixures are good for when you want to run the same test with different parameters (like we do in `test_pip_install_deps`). So `pytest.mark.parametrize()` would be perfect for this case. You can either parametrize both `conda_local` and `channel_priority` (if you want to run all the `CONDA_INSTALL_DEPS` tests with both options) or just `channel_priority` (if you want to only test local conda with both options).

For example, here’s the test for running all `CONDA_INSTALL_DEPS` with both local and `channel_priority` options:
„`python
@pytest.mark.parametrize([„conda_local”, „channel_priority”], [(False, „default”), (True, „default”), (True, „conda-forge”)])
def test_conda_install_deps(conda_local, channel_priority):
„””Test conda install dependencies.”””
deps = sorted(_get_install_deps(„conda”, local=conda_local, channel_priority=channel_priority).keys())
assert deps == CONDA_INSTALL_DEPS
„`

Note that we don’t have to test `local = False` and `channel_priority = „conda-forge”` because when `conda_local = False`, we ignore `channel_priority` anyway (see line 144 of `depfinder/main.py`).

If you want to only test `local = True` and both `channel_priority` options, then you can do:
„`python
@pytest.mark.parametrize(„channel_priority”, [„default”, „conda-forge”])
def test_conda_install_deps(channel_priority):
„””Test conda install dependencies.”„
deps = sorted(_get_install_deps(„conda”, local=True, channel_priority=channel_priority).keys())
assert deps == CONDA_INSTALL_DEPS
„`

Let me know if you think one of these options would work for you, or if you’d prefer to try something else!
username_0: Thanks, @username_1! I think the first approach with testing both `conda_local` and `channel_priority` makes more sense since we’re testing all possible scenarios.

I’ll create a PR with this solution. Please let me know if you think if this is the right approach. Thanks again!

Idź do oryginalnego materiału