1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VSCode でリモートの pytest を uv を使って実行

Posted at

やりたいこと

Linux 上の uv を使った django のテストコードを Windows 上の VSCode で実行する。

VSCode でリモートの pytest のテストコードを実行」ではデフォルトの python で実行したが、ここでは uv でインストールした python を使用する。

VSCode の設定

pytest で uv でインストールした python を使用するよう設定を行う。

  • 左メニューのフラスコをクリック
  • Ctrl + Shift + P でコマンドパレットを表示
  • コマンドパレットで Python: select interpreter を選択
  • インタープリタとして .venv/bin/python を選択
    interpreter.png

uv の設定

pyproject.toml

既存の pytest1 ディレクトリに pyproject.toml を作成する。

$ uv init pytest1

パッケージのインストール

必要なパッケージのインストールを行う。

$ cd pytest1
$ uv add django==5.2
$ uv add django-tenants
$ uv add django-tenant-schemas
$ uv add pytest
$ uv add pytest-django
$ uv add psycopg2

テストスクリプトの実行

  • 左メニューのフラスコをクリック

  • ブレークポイントを指定した場合には、Debug Test アイコンをクリックしてテストを実行
    execute.png

  • ブレークポイントで一時停止し、変数の値などが表示される
    breakpoint - コピー.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?