python

# virtual environment

```sh
root@tokunori-desktop:/home/tokunori/nvme-cli# nose2 --verbose --start-dir tests nvme_create_max_ns_test
Traceback (most recent call last):
  File "/home/tokunori/.local/bin/nose2", line 5, in <module>
    from nose2 import discover
ModuleNotFoundError: No module named 'nose2'
root@tokunori-desktop:/home/tokunori/nvme-cli# pip3 install nose2
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
root@tokunori-desktop:/home/tokunori/nvme-cli# python3 -m venv /home/tokunori/nvme-cli
root@tokunori-desktop:/home/tokunori/nvme-cli# ./bin/nose2 --verbose --start-dir tests nvme_create_max_ns_test
test_attach_detach_ns (nvme_create_max_ns_test.TestNVMeCreateMaxNS.test_attach_detach_ns)
Testcase main ... 
Using nvme binary 'nvme'
FAIL



======================================================================
FAIL: test_attach_detach_ns (nvme_create_max_ns_test.TestNVMeCreateMaxNS.test_attach_detach_ns)
Testcase main
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tokunori/nvme-cli/tests/nvme_create_max_ns_test.py", line 50, in setUp
    super().setUp()
  File "/home/tokunori/nvme-cli/tests/nvme_test.py", line 80, in setUp
    self.create_and_attach_default_ns()
  File "/home/tokunori/nvme-cli/tests/nvme_test.py", line 107, in create_and_attach_default_ns
    self.ctrl_id = self.get_ctrl_id()
                   ^^^^^^^^^^^^^^^^^^
  File "/home/tokunori/nvme-cli/tests/nvme_test.py", line 206, in get_ctrl_id
    self.assertEqual(err, 0, "ERROR : nvme list-ctrl failed")
AssertionError: 1 != 0 : ERROR : nvme list-ctrl failed

----------------------------------------------------------------------
Ran 1 test in 0.091s

FAILED (failures=1)
root@tokunori-desktop:/home/tokunori/nvme-cli# ./bin/nose2 --verbose --start-dir tests nvme_create_max_ns_test
test_attach_detach_ns (nvme_create_max_ns_test.TestNVMeCreateMaxNS.test_attach_detach_ns)
Testcase main ... 
Using nvme binary '.build/nvme'
##### Creating 1
FAIL



======================================================================
FAIL: test_attach_detach_ns (nvme_create_max_ns_test.TestNVMeCreateMaxNS.test_attach_detach_ns)
Testcase main
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tokunori/nvme-cli/tests/nvme_create_max_ns_test.py", line 50, in setUp
    super().setUp()
  File "/home/tokunori/nvme-cli/tests/nvme_test.py", line 82, in setUp
    err = self.create_and_validate_ns(nsid,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokunori/nvme-cli/tests/nvme_test.py", line 388, in create_and_validate_ns
    self.assertEqual(int(json_output['nsid']), nsid,
AssertionError: 2 != 1 : ERROR : create namespace failed

----------------------------------------------------------------------
Ran 1 test in 0.079s

FAILED (failures=1)
root@tokunori-desktop:/home/tokunori/nvme-cli# 
```

# link

https://qiita.com/toiee_kame/items/c3781abb53f385dae4f9