postgrespro/testgres

NodeApp::make_empty has a problem with base_dir = None

Closed this issue · 1 comments

testgres/testgres/node.py

Lines 2377 to 2382 in d6be913

def make_empty(
self,
base_dir=None,
port=None,
bin_dir=None):
real_base_dir = self.os_ops.build_path(self.test_path, base_dir)

NodeApp.make_empty fails when base_dir is None.

Exception has occurred: TypeError
join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
  File "/home/linuxbrew/.linuxbrew/opt/python@3.13/lib/python3.13/posixpath.py", line 82, in join
    b = os.fspath(b)
TypeError: expected str, bytes or os.PathLike object, not NoneType

During handling of the above exception, another exception occurred:

  File "/home/dima/MY/GitHub2/testgres/master/work02/testgres/operations/local_ops.py", line 257, in build_path
    return os.path.join(a, *parts)
           ~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/dima/MY/GitHub2/testgres/master/work02/testgres/node_app.py", line 66, in make_empty
    real_base_dir = self._os_ops.build_path(self._test_path, base_dir)
  File "/home/dima/MY/GitHub2/testgres/master/work02/testgres/node_app.py", line 95, in make_simple
    node = self.make_empty(
  File "/home/dima/MY/GitHub2/testgres/master/work02/tests/test_testgres_common.py", line 1599, in test_node_app__make_simple__checksum
    with app.make_simple(checksum=False):

Attention

By default NodeApp uses CWD as (root) test path:

self.test_path = os_ops.cwd()

If you call NodeApp.make_empty (or NodeApp.male_simple) with empty base_dir (""), testgres will delete your current directory:

testgres/testgres/node.py

Lines 2382 to 2383 in 69f8d49

real_base_dir = self.os_ops.build_path(self.test_path, base_dir)
self.os_ops.rmdirs(real_base_dir, ignore_errors=True)

CWD may be a path to your a copy of testgres project or your application.