<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - pytest</title>
    <link>https://emresahin.net/tags/pytest/</link>
    <description>Posts in the pytest tag</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 29 Sep 2026 14:57:43 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/tags/pytest/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>devlog 12</title>
      <published>2025-01-19T09:46:29+00:00</published>
      <updated>2025-01-19T09:46:29+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sun, 19 Jan 2025 09:46:29 +0000</pubDate>
      <link>https://emresahin.net/devlog-12/</link>
      <guid isPermaLink="true">https://emresahin.net/devlog-12/</guid>
      <description>🐢 What are today’s plans? 🐇 I think we can start by improving xvc.py. I mean, releasing. Yesterday we finished our work with the Rust library. 🐢 Then we can start to look at the GUI, I believe. We can replace that 3-column view with a table and preview. It will be much easier that way. 🐇 Yep. Let...</description>
      <category>xvc</category>
      <category>xvc.py</category>
      <category>pypi</category>
      <category>maturin</category>
      <category>pytest</category>
      <category>xvc-test-helper</category>
      <category>codecov</category>
      <category>coverage</category>
      <category>GitHub Actions</category>
      <category>Python</category>
      <category>Rust</category>
      <category>PyO3</category>
      <content:encoded><![CDATA[<p>🐢 What are today’s plans?</p>
<p>🐇 I think we can start by improving xvc.py. I mean, releasing. Yesterday we finished our work with the Rust library.</p>
<p>🐢 Then we can start to look at the GUI, I believe. We can replace that 3-column view with a table and preview. It will be much easier that way.</p>
<p>🐇 Yep. Let’s finish and release the Python version first. Then we’ll go on to the GUI.</p>
<p>🐢 Let’s take a look at the PRs first.</p>
<pre><code>ghpl 
36	Bump pyo3 from 0.22.2 to 0.23.3	dependabot/cargo/pyo3-0.23.3	OPEN	2024-12-04T03:52:03Z

gh pr close 36
✓ Closed pull request iesahin/xvc.py#36 (Bump pyo3 from 0.22.2 to 0.23.3)
</code></pre>
<p>🐢 We have already upgraded to pyo3 0.23. No need for this. Let’s create a PR for the current branch.</p>
<pre><code>git push --set-upstream origin v0.6.13

ghpC --fill
https://github.com/iesahin/xvc.py/pull/37
</code></pre>
<p>🐇 We can also tag and push the tags.</p>
<p>🐢 I’d like to have some more coverage for certain parts of the code. Let’s add some tests.</p>
<p>🐇 It looks like we mainly lack the storage tests. They need configuration to add keys to GitHub, and we already skip some of these even in the Rust code.</p>
<p>🐢 Umm, I see. We also need a way to measure coverage. Could we do this with Codecov, I wonder?</p>
<p>🐇 I found an example here: https://github.com/codecov/example-python/blob/main/.github/workflows/ci.yml. It needs <code>coverage</code> and <code>pytest-cov</code> in the requirements.</p>
<p>🐢 Let’s try this then.</p>
<p>🐇 Added <code>coverage.yml</code> file. It’s simpler than the other GitHub action. Need to update the token now.</p>
<p>🐢 There is an issue installing the requirements.</p>
<p>🐇 I forgot to add <code>sudo</code> to <code>apt-get</code>. Will take care of it now.</p>
<p>🐢 Let’s check the run.</p>
<pre><code>ghrl
in_progress		Release v0.6.13	coverage	v0.6.13	pull_request	12556590550	2m31s	2024-12-31T06:59:58Z
in_progress		Release v0.6.13	publish-to-pypi	v0.6.13	pull_request	12556590548	2m31s	2024-12-31T06:59:58Z
...
</code></pre>
<p>🐇 It takes a while and we still didn’t add the <code>CODECOV_TOKEN</code>.</p>
<p>🐢 Let’s add it, and after that, we need to take a look at this <code>blink</code> configuration. It adds letters after the selection.</p>
<p>🐇 Added the secret and configured <code>xvc.py</code> for coverage. There is an error with the build, though. Maybe the command we should be using is <code>maturin develop</code> instead of <code>build</code> to make Xvc available for the environment.</p>
<p>🐢 Let’s update and try it then.</p>
<p>🐇 <code>maturin develop</code> requires a virtual environment.</p>
<p>🐢 I checked the options for <code>build</code>, and I think there is an option, but let’s search first.</p>
<p>🐇 I searched, but it looks like we can just pass an <code>--out</code> directory or install <code>xvc</code> from the <code>target/wheels/</code> directory. The second option requires less maintenance.</p>
<p>🐢 Okay. Let’s add a step to the action then.</p>
<p>🐇 Now, let’s wait for the run to finish with <code>gh run watch</code>.</p>
<p>🐢 It failed. Let’s take a look at the logs:</p>
<pre><code>ghrl
completed	failure	Release v0.6.13	coverage	v0.6.13	pull_request	12556939836	3m26s	2024-12-31T07:38:54Z

gh run view 12556939836 --log-failed
</code></pre>
<p>🐇 It looks like some of the tests are failing. Let’s run the tests locally.</p>
<p>🐢 We should run with the <code>--forked</code> option, and it looks like we have a test to update with the xvc file list.</p>
<p>🐇 Updated the test, and I noticed we forgot to supply the new <code>--show-directories</code> option in the Python interface.</p>
<p>🐢 Yep. Passing these options as command-line options in strings is not robust. It’s very easy to forget things. I think we should start using CLI structs directly, but it’s not time yet.</p>
<p>🐇 I agree. It’s one of the goals for building a GUI, actually.</p>
<p>🐢 The tests failed again.</p>
<pre><code>ghrl | rg failure
completed	failure	Release v0.6.13	coverage	v0.6.13	pull_request	12557031091	3m49s	2024-12-31T07:51:19Z

gh run view 12557031091 --log-failed
</code></pre>
<p>🐇 There is a Git error now. We need to add a Git user and email to the action.</p>
<p>🐢 Added those and watching the results again now.</p>
<p>🐇 Why do you think the publish action always works? It can only run with the main branch, I think. No need to run it with other pushes.</p>
<p>🐢 Yes, let’s configure it now.</p>
<pre><code>ghrl | rg failure
completed	failure	Release v0.6.13	coverage	v0.6.13	pull_request	12557083393	3m21s	2024-12-31T07:59:18Z

gh run view 12557083393 --log-failed
</code></pre>
<p>🐇 It looks like we also need <code>xvc-test-helper</code> in the path. Let’s <code>cargo install</code> it and add it to the path.</p>
<p>🐢 Added <code>.cargo/bin</code> to the path like:</p>
<pre><code class="language-yaml">- name: Add cargo bin to PATH
  run: echo "$HOME/.cargo/bin" &gt;&gt; $GITHUB_PATH
</code></pre>
<p>and installed the helper with <code>cargo install xvc-test-helper</code>.</p>
<p>🐇 By the way, GitHub Copilot is hallucinating about a method to update the path.</p>
<p>🐢 I searched and it may not be hallucinating. We can use the <code>::add-path::</code> command with <code>echo</code>, it looks like. This is new to me.</p>
<p>🐇 The tests failed again.</p>
<pre><code>ghrl | rg failure
completed	failure	Release v0.6.13	coverage	v0.6.13	pull_request	12557208723	3m34s	2024-12-31T08:12:09Z

gh run view 12557208723 --log-failed
</code></pre>
<p>🐢 <code>file().list()</code> had a mistake, and we need to install <code>rg</code> for the tests.</p>
<p>🐇 Watching the test run. In the meantime, maybe we can review…</p>
<p>🐢 Failed again.</p>
<pre><code>ghrl | rg failure
completed	failure	Release v0.6.13	coverage	v0.6.13	pull_request	12557294105	3m46s	2024-12-31T08:21:17Z

gh run view 12557294105 --log-failed
</code></pre>
<p>🐇 Added <code>db.commit()</code> to two places in the code. This should pass now.</p>
<p>🐢 Yeah!</p>
<pre><code>ghrl | head -n 1
completed	success	Release v0.6.13	coverage	v0.6.13	pull_request	12557509836	3m46s	2024-12-31T08:44:33Z

gh run view 12557509836

✓ v0.6.13 coverage iesahin/xvc.py#37 · 12557509836
Triggered via pull_request about 4 minutes ago

JOBS
✓ linux in 3m36s (ID 35010253915)

ANNOTATIONS
! ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
linux: .github#1


For more information about the job, try: gh run view --job=35010253915
View this run on GitHub: https://github.com/iesahin/xvc.py/actions/runs/12557509836
</code></pre>
<p>🐇 I can’t see a coverage report on codecov.io, though.</p>
<p>🐢 It says no coverage report is generated. Let’s test to generate XML files locally.</p>
<p>🐇 The option in the docs seems incorrect. <code>--cov-branch</code> doesn’t produce anything.</p>
<p>🐢 Let’s wait for the run again.</p>
<p>🐇 Should we add a badge to the README?</p>
<p>🐢 It won’t show much, but yeah, let’s make it.</p>
<p>🐇 The results are in and it shows 100% coverage. This means it doesn’t actually test anything.</p>
<p>🐢 We need Rust coverage for this. Let’s search for it.</p>
<p>🐇 I found this: https://github.com/cjermain/rust-python-coverage. It runs <code>cargo llvm-cov</code> with the project and measures test coverage. But we don’t have any Rust tests.</p>
<p>🐢 It looks like we don’t need Rust tests. <code>cargo llvm-cov</code> can check coverage with the Python as well.</p>
<pre><code class="language-bash">$ cargo llvm-cov show-env --export-prefix
export RUSTFLAGS=" -C instrument-coverage --cfg coverage --cfg trybuild_no_target"
export LLVM_PROFILE_FILE="/home/.../rust-python-coverage/target/rust-python-coverage-%m.profraw"
export CARGO_INCREMENTAL="0"
export CARGO_LLVM_COV_TARGET_DIR="/home/.../rust-python-coverage/target"
</code></pre>
<hr>
<p>🐢 Let’s take a look at what remained for 0.6.13.</p>
<p>🐇 I think there is nothing left. Python must be published when we merged the PR.</p>
<p>🐢 Let’s take a look by searching xvc python.</p>
<p>🐇 The PyPI page is https://pypi.org/project/xvc/ and it still reports the version as 0.6.11. There must be something.</p>
<p>🐢 Now let’s take a look at</p>
<p>https://github.com/iesahin/xvc.py</p>
<p>🐇 The run seems to be OK though.</p>
<p>https://github.com/iesahin/xvc.py/actions/runs/12557780141/job/35010938462</p>
<p>🐢 Maybe the version in <code>pyproject.toml</code> is still 0.6.11 and we forgot to update it?</p>
<p>tmux new-window -c $HOME/github.com/iesahin/xvc.py/ nvim</p>
<p>🐇 There is no version string in <code>~/github.com/iesahin/xvc.py/pyproject.toml</code>. It’s <em>dynamic</em>.</p>
<p>🐢 Then, let’s try to publish from local now.</p>
<p>🐇 The <code>iex</code> username requires email verification.</p>
<p>🐢 It looks like I publish xvc through the <code>iesahin</code> account, not <code>iex</code>. Maybe I can add both accounts to the project.</p>
<p>🐇 There seem to be no errors on the PyPI site.</p>
<p>🐢 Updating the token. Let’s add the token to pass to run <code>maturin publish</code>.</p>
<p>🐇 We’re receiving invalid or non-existent authentication information. Upgraded <code>maturin</code> to see if it fixes the issue.</p>
<p>🐢 We can also double-check the key.</p>
<p>🐇 Uploaded successfully from local. Let’s check the job again.</p>
<p>🐢 The release job was skipped because we didn’t tag after the merge. https://github.com/iesahin/xvc.py/actions/runs/12557780141/job/35011303045 That looks like the reason.</p>
<p>🐇 I should be more careful which is run and which is skipped.</p>
<p>🐢 Maybe we can relax the condition. We do this rarely. Maybe republishing is alright?</p>
<p>🐇 Yep, removed that. The jobs are running now. Let’s watch them to see what happens when we publish some of the packages.</p>
<p>🐢 In the meantime, let’s experiment with searching commands file with <code>fzf-lua</code>.</p>
<p>🐇 It requires more experimentation, but we can start from https://github.com/ibhagwan/fzf-lua/wiki/Advanced#interactive-shell-command.</p>
<p>🐢 The xvc publish jobs failed, btw.</p>
<pre><code>ghrl
completed	failure	Remove if condition from release	publish-to-pypi	v0.6.13	push	12568863716	15m26s	2025-01-01T08:30:03Z

gh run view 12568863716 --log-failed
...
Release	Run actions/download-artifact@v4.1.7	        Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact.
...
</code></pre>
<p>🐇 It was using an older version of <code>upload-artifact</code>.</p>
<p>🐢 Rerunning the job and it looks like it runs for both push to <code>main</code> and tag with <code>v0.6.13</code>. We can turn off push to <code>main</code>, I believe.</p>
<p>🐇 There was a missing <code>upload-artifact</code> again. Fixed and updated the tags.</p>
<p>ghrl
completed	failure	update upload-artifacts	publish-to-pypi	main	push	12569060915	14m39s	2025-01-01T08:57:22Z</p>
<p>ghrf 12569060915</p>
<p>🐢 There are conflicts with uploaded artifacts now. We may need to clean up the artifacts manually.</p>
<p>🐇 The conflicts were not about inter-workflow names. The names were conflicting because all files were named <code>wheel</code>. I added the platform and target to the names to avoid conflicts.</p>
<p>🐢 Let’s wait then. Maybe it will work this time. Could you search for a Lua console for Neovim?</p>
<p>🐇 Let’s try this one: return {
“yarospace/lua-console.nvim”,
lazy = true, keys = “`”, opts = {},
}</p>
<p>🐢 I couldn’t make it run but won’t spend much time ATM. How about the jobs?</p>
<pre><code>ghrl
completed	failure	update upload artifact names	publish-to-pypi	v0.6.13	push	12569298414	13m57s	2025-01-01T09:27:00Z

ghrf 12569298414
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9180510Z ##[group]Run actions/download-artifact@v4
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9182098Z with:
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9182859Z   name: wheels
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9183843Z   merge-multiple: false
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9184817Z   repository: iesahin/xvc.py
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9185820Z   run-id: 12569298414
Release	Run actions/download-artifact@v4	2025-01-01T09:40:52.9186903Z ##[endgroup]
Release	Run actions/download-artifact@v4	2025-01-01T09:40:53.1937617Z Downloading single artifact
Release	Run actions/download-artifact@v4	2025-01-01T09:40:53.4694769Z ##[error]Unable to download artifact(s): Artifact not found for name: wheels
Release	Run actions/download-artifact@v4	        Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact.
Release	Run actions/download-artifact@v4	        For more information, visit the GitHub Artifacts FAQ: https://github.com/actions/toolkit/blob/main/packages/artifact/docs/faq.md
</code></pre>
<p>🐇 Now the download doesn’t work.</p>
<p>🐢 Update it to download using patterns.</p>
<p>🐇 Did so and let’s take a look at the jobs again.</p>
<pre><code>ghrl
completed	failure	added pattern to download	.github/workflows/publish.yml	main	push	12569456859	0s	2025-01-01T09:49:19Z

ghrv 12569456859

X main .github/workflows/publish.yml · 12569456859
Triggered via push about 3 minutes ago

X This run likely failed because of a workflow file issue.

For more information, see: https://github.com/iesahin/xvc.py/actions/runs/12569456859
</code></pre>
<p>🐢 The line with the pattern was reported as broken.</p>
<p>🐇  Removed it and recommitted.</p>
<pre><code>ghrl
✅ completed	success	remove pattern to download all	publish-to-pypi	v0.6.13	push	12569509435	14m41s	2025-01-01T09:58:49Z
</code></pre>
<p>🐢 And now this completes the <code>v0.6.13</code> release.</p>
<p>🐇 We’ll see how it will work next time.</p>
<p>🐢 Yep. Let’s move on to the GUI for now. Is that okay with you?</p>]]></content:encoded>
    </item>
    <item>
      <title>devlog 6</title>
      <published>2024-07-12T08:53:14+00:00</published>
      <updated>2024-07-12T08:53:14+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Fri, 12 Jul 2024 08:53:14 +0000</pubDate>
      <link>https://emresahin.net/devlog-6/</link>
      <guid isPermaLink="true">https://emresahin.net/devlog-6/</guid>
      <description>I have a habit of testing against the CLI’s help string output. It allows me to keep the documentation up to date and makes me aware of any undocumented options. When new features are added, the help text changes and the test fails, which prompts me to add those options to the documentation. I tr...</description>
      <category>devlog</category>
      <category>Software Development</category>
      <category>xvc</category>
      <category>Python</category>
      <category>pytest</category>
      <category>clap</category>
      <category>CLI</category>
      <category>Testing</category>
      <content:encoded><![CDATA[<p>I have a habit of testing against the CLI’s help string output. It allows me to
keep the documentation up to date and makes me aware of any undocumented options.
When new features are added, the help text changes and the test fails, which
prompts me to add those options to the documentation.</p>
<p>I tried the same approach when testing Python bindings with Pytest:</p>
<pre><code class="language-python">def test_pipeline_step_dependency(empty_xvc_repo):
    dep_help = empty_xvc_repo.pipeline().step().dependency(help=True)
    expected = """
Usage: xvc pipeline step dependency [OPTIONS] --step-name &lt;STEP_NAME&gt;

Options:
  -s, --step-name &lt;STEP_NAME&gt;
          Name of the step to add the dependency to
"""
    assert dep_help == expected
</code></pre>
<p>This doesn’t work because the help text is generated by <a href="https://docs.rs/clap/latest/clap/">clap</a> and skips the usual
thread-based output handler. All command output and errors in Xvc are returned
as strings from the command, except for the help text that’s generated by <a href="https://docs.rs/clap/latest/clap/">clap</a>
automatically.</p>
<p>There are probably workarounds for this, but I won’t pursue them further as I don’t
test the actual functionality in the Python bindings anyway.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
