Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the test for \pipe_once command. #1177

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Changes from all commits
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
18 changes: 10 additions & 8 deletions test/test_special_iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_editor_command():
if os.name != 'nt':
mycli.packages.special.open_external_editor(sql=r'select 1') == "select 1"
else:
pytest.skip('Skipping on Windows platform.')
pytest.skip('Skipping on Windows platform.')



Expand Down Expand Up @@ -92,7 +92,7 @@ def test_tee_command():
os.remove(f.name)
except Exception as e:
print(f"An error occurred while attempting to delete the file: {e}")



def test_tee_command_error():
Expand All @@ -106,7 +106,7 @@ def test_tee_command_error():


@dbtest

@pytest.mark.skipif(os.name == "nt", reason="Bug: fails on Windows, needs fixing, singleton of FQ not working right")
def test_favorite_query():
with db_connection().cursor() as cur:
Expand Down Expand Up @@ -162,17 +162,19 @@ def test_pipe_once_command():
mycli.packages.special.write_once(u"hello world")
mycli.packages.special.unset_pipe_once_if_written()
else:
mycli.packages.special.execute(None, u"\\pipe_once wc")
mycli.packages.special.write_once(u"hello world")
mycli.packages.special.unset_pipe_once_if_written()
# how to assert on wc output?
with tempfile.NamedTemporaryFile() as f:
mycli.packages.special.execute(None, "\\pipe_once tee " + f.name)
mycli.packages.special.write_pipe_once(u"hello world")
mycli.packages.special.unset_pipe_once_if_written()
f.seek(0)
assert f.read() == b"hello world\n"


def test_parseargfile():
"""Test that parseargfile expands the user directory."""
expected = {'file': os.path.join(os.path.expanduser('~'), 'filename'),
'mode': 'a'}

if os.name=='nt':
assert expected == mycli.packages.special.iocommands.parseargfile(
'~\\filename')
Expand Down