Skip to content

Commit

Permalink
Fix the test for \pipe_once command.
Browse files Browse the repository at this point in the history
  • Loading branch information
amjith committed Nov 16, 2024
1 parent 640f174 commit 151549d
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 151549d

Please sign in to comment.