Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Test refactoring#236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
TestConfig is added
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedApr 6, 2025
commit88ca53dd232e0dded2566d52acb79bf9fd0750de
41 changes: 41 additions & 0 deletionstests/test_config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
from ..testgres import TestgresConfig
from ..testgres import configure_testgres
from ..testgres import scoped_config
from ..testgres import pop_config

from .. import testgres

import pytest


class TestConfig:
def test_config_stack(self):
# no such option
with pytest.raises(expected_exception=TypeError):
configure_testgres(dummy=True)

# we have only 1 config in stack
with pytest.raises(expected_exception=IndexError):
pop_config()

d0 = TestgresConfig.cached_initdb_dir
d1 = 'dummy_abc'
d2 = 'dummy_def'

with scoped_config(cached_initdb_dir=d1) as c1:
assert (c1.cached_initdb_dir == d1)

with scoped_config(cached_initdb_dir=d2) as c2:
stack_size = len(testgres.config.config_stack)

# try to break a stack
with pytest.raises(expected_exception=TypeError):
with scoped_config(dummy=True):
pass

assert (c2.cached_initdb_dir == d2)
assert (len(testgres.config.config_stack) == stack_size)

assert (c1.cached_initdb_dir == d1)

assert (TestgresConfig.cached_initdb_dir == d0)
37 changes: 1 addition & 36 deletionstests/test_testgres_local.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,11 +14,7 @@
ExecUtilException, \
NodeApp

from ..testgres import \
TestgresConfig, \
configure_testgres, \
scoped_config, \
pop_config
from ..testgres import scoped_config

from ..testgres import \
get_new_node
Expand DownExpand Up@@ -100,37 +96,6 @@ def test_pg_config(self):
b = get_pg_config()
assert (id(a) != id(b))

def test_config_stack(self):
# no such option
with pytest.raises(expected_exception=TypeError):
configure_testgres(dummy=True)

# we have only 1 config in stack
with pytest.raises(expected_exception=IndexError):
pop_config()

d0 = TestgresConfig.cached_initdb_dir
d1 = 'dummy_abc'
d2 = 'dummy_def'

with scoped_config(cached_initdb_dir=d1) as c1:
assert (c1.cached_initdb_dir == d1)

with scoped_config(cached_initdb_dir=d2) as c2:
stack_size = len(testgres.config.config_stack)

# try to break a stack
with pytest.raises(expected_exception=TypeError):
with scoped_config(dummy=True):
pass

assert (c2.cached_initdb_dir == d2)
assert (len(testgres.config.config_stack) == stack_size)

assert (c1.cached_initdb_dir == d1)

assert (TestgresConfig.cached_initdb_dir == d0)

def test_ports_management(self):
assert bound_ports is not None
assert type(bound_ports) == set # noqa: E721
Expand Down
38 changes: 2 additions & 36 deletionstests/test_testgres_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,11 +13,8 @@
InitNodeException, \
ExecUtilException

from ..testgres.config import \
TestgresConfig, \
configure_testgres, \
scoped_config, \
pop_config, testgres_config
from ..testgres.config import scoped_config
from ..testgres.config import testgres_config

from ..testgres import \
get_bin_path, \
Expand DownExpand Up@@ -168,37 +165,6 @@ def test_pg_config(self):
b = get_pg_config()
assert (id(a) != id(b))

def test_config_stack(self):
# no such option
with pytest.raises(expected_exception=TypeError):
configure_testgres(dummy=True)

# we have only 1 config in stack
with pytest.raises(expected_exception=IndexError):
pop_config()

d0 = TestgresConfig.cached_initdb_dir
d1 = 'dummy_abc'
d2 = 'dummy_def'

with scoped_config(cached_initdb_dir=d1) as c1:
assert (c1.cached_initdb_dir == d1)

with scoped_config(cached_initdb_dir=d2) as c2:
stack_size = len(testgres.config.config_stack)

# try to break a stack
with pytest.raises(expected_exception=TypeError):
with scoped_config(dummy=True):
pass

assert (c2.cached_initdb_dir == d2)
assert (len(testgres.config.config_stack) == stack_size)

assert (c1.cached_initdb_dir == d1)

assert (TestgresConfig.cached_initdb_dir == d0)

@staticmethod
def helper__get_node(name=None):
svc = PostgresNodeServices.sm_remote
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp