summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgy Frolov <gosha@fro.lv>2021-03-02 19:05:16 +0300
committerGeorgy Frolov <gosha@fro.lv>2021-03-02 19:33:04 +0300
commit5cb5c6409ec33b27116165b9e2c99155c2dd4630 (patch)
tree5ae5306c86ff2c00c49b3320c40e9f1f97e16d2c
parent2984bcde81ee2d7e61181b3b5a66b5b774d7019f (diff)
relax watch_query testpasenor/ci-macos
-rw-r--r--.github/workflows/ci.yml5
-rw-r--r--mycli/compat.py1
-rw-r--r--mycli/packages/filepaths.py4
-rw-r--r--test/test_special_iocommands.py22
4 files changed, 20 insertions, 12 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 47a0e62..de4159c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -39,6 +39,7 @@ jobs:
- name: Install dependencies
run: |
+ python -c"import sys; print(sys.platform)"
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install --no-cache-dir -e .
@@ -105,19 +106,15 @@ jobs:
- name: Pytest
env:
- PYTEST_USER: root
PYTEST_PASSWORD: root
PYTEST_HOST: 127.0.0.1
- PYTEST_PORT: 3306
run: |
pytest test
- name: Behave
env:
- PYTEST_USER: root
PYTEST_PASSWORD: root
PYTEST_HOST: 127.0.0.1
- PYTEST_PORT: 3306
run: |
behave test/features --no-capture
diff --git a/mycli/compat.py b/mycli/compat.py
index 2ebfe07..a2502ce 100644
--- a/mycli/compat.py
+++ b/mycli/compat.py
@@ -4,3 +4,4 @@ import sys
WIN = sys.platform in ('win32', 'cygwin')
+MAC = sys.platform == 'Darwin'
diff --git a/mycli/packages/filepaths.py b/mycli/packages/filepaths.py
index 79fe26d..873a019 100644
--- a/mycli/packages/filepaths.py
+++ b/mycli/packages/filepaths.py
@@ -1,9 +1,11 @@
import os
import platform
+from mycli.compat import MAC
+
if os.name == "posix":
- if platform.system() == "Darwin":
+ if MAC:
DEFAULT_SOCKET_DIRS = ("/tmp",)
else:
DEFAULT_SOCKET_DIRS = ("/var/run", "/var/lib")
diff --git a/test/test_special_iocommands.py b/test/test_special_iocommands.py
index 73bfbab..5e70626 100644
--- a/test/test_special_iocommands.py
+++ b/test/test_special_iocommands.py
@@ -8,6 +8,7 @@ import pytest
from pymysql import ProgrammingError
import mycli.packages.special
+from mycli.compat import WIN, MAC
from .utils import dbtest, db_connection, send_ctrl_c
@@ -166,18 +167,24 @@ def test_watch_query_full():
"""Test that `watch_query`:
* Returns the expected results.
- * Executes the defined times inside the given interval, in this case with
- a 0.3 seconds wait, it should execute 4 times inside a 1 seconds
- interval.
+ * Executes the defined times inside the given interval
* Stops at Ctrl-C
"""
- watch_seconds = 0.3
- wait_interval = 1
+ if WIN or MAC:
+ # Timing of ctrl_c sending on Windows and macOS seems
+ # more approximate than on Linux.
+ # We basically just check that there are "a lot of queries"
+ watch_seconds = 0.3
+ wait_interval = 3
+ expected_results = (9, 15)
+ else:
+ watch_seconds = 0.3
+ wait_interval = 1
+ expected_results = (4, 4)
expected_value = "1"
query = "SELECT {0!s}".format(expected_value)
expected_title = '> {0!s}'.format(query)
- expected_results = 4
ctrl_c_process = send_ctrl_c(wait_interval)
with db_connection().cursor() as cur:
results = list(
@@ -186,7 +193,8 @@ def test_watch_query_full():
)
)
ctrl_c_process.join(1)
- assert len(results) == expected_results
+ low, high = expected_results
+ assert low <= len(results) <= high
for result in results:
assert result[0] == expected_title
assert result[2][0] == expected_value