Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 9ba22ef

Browse files
authored
Use pytest in integration test (apache#715)
* use pytest * update to use pytest
1 parent 2176ff5 commit 9ba22ef

File tree

4 files changed

+153
-22
lines changed

4 files changed

+153
-22
lines changed

.github/workflows/rust.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
- name: Install Python dependencies
164164
run: |
165165
python -m pip install --upgrade pip setuptools wheel
166-
python -m pip install --upgrade numpy==1.20.3 pandas==1.2.4
166+
python -m pip install -r integration-tests/requirements.txt
167167
- name: Allow access of psql
168168
run: |
169169
# make sure psql can access the server
@@ -194,7 +194,7 @@ jobs:
194194
- name: Build datafusion-cli
195195
run: cargo build --bin datafusion-cli
196196
- name: Test Psql Parity
197-
run: python -m unittest -v integration-tests/test_psql_parity.py
197+
run: python -m pytest -v integration-tests/test_psql_parity.py
198198
env:
199199
POSTGRES_HOST: localhost
200200
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}

integration-tests/requirements.in

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
pytest
17+
numpy
18+
pandas

integration-tests/requirements.txt

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file is autogenerated by pip-compile with python 3.8
18+
# To update, run:
19+
#
20+
# pip-compile --generate-hashes
21+
#
22+
attrs==21.2.0 \
23+
--hash=sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1 \
24+
--hash=sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb
25+
# via pytest
26+
iniconfig==1.1.1 \
27+
--hash=sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3 \
28+
--hash=sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32
29+
# via pytest
30+
numpy==1.21.0 \
31+
--hash=sha256:1a784e8ff7ea2a32e393cc53eb0003eca1597c7ca628227e34ce34eb11645a0e \
32+
--hash=sha256:2ba579dde0563f47021dcd652253103d6fd66165b18011dce1a0609215b2791e \
33+
--hash=sha256:3537b967b350ad17633b35c2f4b1a1bbd258c018910b518c30b48c8e41272717 \
34+
--hash=sha256:3c40e6b860220ed862e8097b8f81c9af6d7405b723f4a7af24a267b46f90e461 \
35+
--hash=sha256:598fe100b2948465cf3ed64b1a326424b5e4be2670552066e17dfaa67246011d \
36+
--hash=sha256:620732f42259eb2c4642761bd324462a01cdd13dd111740ce3d344992dd8492f \
37+
--hash=sha256:709884863def34d72b183d074d8ba5cfe042bc3ff8898f1ffad0209161caaa99 \
38+
--hash=sha256:75579acbadbf74e3afd1153da6177f846212ea2a0cc77de53523ae02c9256513 \
39+
--hash=sha256:7c55407f739f0bfcec67d0df49103f9333edc870061358ac8a8c9e37ea02fcd2 \
40+
--hash=sha256:a1f2fb2da242568af0271455b89aee0f71e4e032086ee2b4c5098945d0e11cf6 \
41+
--hash=sha256:a290989cd671cd0605e9c91a70e6df660f73ae87484218e8285c6522d29f6e38 \
42+
--hash=sha256:ac4fd578322842dbda8d968e3962e9f22e862b6ec6e3378e7415625915e2da4d \
43+
--hash=sha256:ad09f55cc95ed8d80d8ab2052f78cc21cb231764de73e229140d81ff49d8145e \
44+
--hash=sha256:b9205711e5440954f861ceeea8f1b415d7dd15214add2e878b4d1cf2bcb1a914 \
45+
--hash=sha256:bba474a87496d96e61461f7306fba2ebba127bed7836212c360f144d1e72ac54 \
46+
--hash=sha256:bebab3eaf0641bba26039fb0b2c5bf9b99407924b53b1ea86e03c32c64ef5aef \
47+
--hash=sha256:cc367c86eb87e5b7c9592935620f22d13b090c609f1b27e49600cd033b529f54 \
48+
--hash=sha256:ccc6c650f8700ce1e3a77668bb7c43e45c20ac06ae00d22bdf6760b38958c883 \
49+
--hash=sha256:cf680682ad0a3bef56dae200dbcbac2d57294a73e5b0f9864955e7dd7c2c2491 \
50+
--hash=sha256:d2910d0a075caed95de1a605df00ee03b599de5419d0b95d55342e9a33ad1fb3 \
51+
--hash=sha256:d5caa946a9f55511e76446e170bdad1d12d6b54e17a2afe7b189112ed4412bb8 \
52+
--hash=sha256:d89b0dc7f005090e32bb4f9bf796e1dcca6b52243caf1803fdd2b748d8561f63 \
53+
--hash=sha256:d95d16204cd51ff1a1c8d5f9958ce90ae190be81d348b514f9be39f878b8044a \
54+
--hash=sha256:e4d5a86a5257843a18fb1220c5f1c199532bc5d24e849ed4b0289fb59fbd4d8f \
55+
--hash=sha256:e58ddb53a7b4959932f5582ac455ff90dcb05fac3f8dcc8079498d43afbbde6c \
56+
--hash=sha256:e80fe25cba41c124d04c662f33f6364909b985f2eb5998aaa5ae4b9587242cce \
57+
--hash=sha256:eda2829af498946c59d8585a9fd74da3f810866e05f8df03a86f70079c7531dd \
58+
--hash=sha256:fd0a359c1c17f00cb37de2969984a74320970e0ceef4808c32e00773b06649d9
59+
# via
60+
# -r requirements.in
61+
# pandas
62+
packaging==21.0 \
63+
--hash=sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7 \
64+
--hash=sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14
65+
# via pytest
66+
pandas==1.3.0 \
67+
--hash=sha256:08eeff3da6a188e24db7f292b39a8ca9e073bf841fbbeadb946b3ad5c19d843e \
68+
--hash=sha256:1ff13eed501e07e7fb26a4ea18a846b6e5d7de549b497025601fd9ccb7c1d123 \
69+
--hash=sha256:522bfea92f3ef6207cadc7428bda1e7605dae0383b8065030e7b5d0266717b48 \
70+
--hash=sha256:7897326cae660eee69d501cbfa950281a193fcf407393965e1bc07448e1cc35a \
71+
--hash=sha256:798675317d0e4863a92a9a6bc5bd2490b5f6fef8c17b95f29e2e33f28bef9eca \
72+
--hash=sha256:7d3cd2c99faa94d717ca00ea489264a291ad7209453dffbf059bfb7971fd3a61 \
73+
--hash=sha256:823737830364d0e2af8c3912a28ba971296181a07950873492ed94e12d28c405 \
74+
--hash=sha256:872aa91e0f9ca913046ab639d4181a899f5e592030d954d28c2529b88756a736 \
75+
--hash=sha256:88864c1e28353b958b1f30e4193818519624ad9a1776921622a6a2a016d5d807 \
76+
--hash=sha256:92835113a67cbd34747c198d41f09f4b63f6fe11ca5643baebc7ab1e30e89e95 \
77+
--hash=sha256:98efc2d4983d5bb47662fe2d97b2c81b91566cb08b266490918b9c7d74a5ef64 \
78+
--hash=sha256:b10d7910ae9d7920a5ff7816d794d99acbc361f7b16a0f017d4fa83ced8cb55e \
79+
--hash=sha256:c554e6c9cf2d5ea1aba5979cc837b3649539ced0e18ece186f055450c86622e2 \
80+
--hash=sha256:c746876cdd8380be0c3e70966d4566855901ac9aaa5e4b9ccaa5ca5311457d11 \
81+
--hash=sha256:c81b8d91e9ae861eb4406b4e0f8d4dabbc105b9c479b3d1e921fba1d35b5b62a \
82+
--hash=sha256:e6b75091fa54a53db3927b4d1bc997c23c5ba6f87acdfe1ee5a92c38c6b2ed6a \
83+
--hash=sha256:ed4fc66f23fe17c93a5d439230ca2d6b5f8eac7154198d327dbe8a16d98f3f10 \
84+
--hash=sha256:f058c786e7b0a9e7fa5e0b9f4422e0ccdd3bf3aa3053c18d77ed2a459bd9a45a \
85+
--hash=sha256:fe7a549d10ca534797095586883a5c17d140d606747591258869c56e14d1b457
86+
# via -r requirements.in
87+
pluggy==0.13.1 \
88+
--hash=sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0 \
89+
--hash=sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d
90+
# via pytest
91+
py==1.10.0 \
92+
--hash=sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3 \
93+
--hash=sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a
94+
# via pytest
95+
pyparsing==2.4.7 \
96+
--hash=sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1 \
97+
--hash=sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b
98+
# via packaging
99+
pytest==6.2.4 \
100+
--hash=sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b \
101+
--hash=sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890
102+
# via -r requirements.in
103+
python-dateutil==2.8.1 \
104+
--hash=sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c \
105+
--hash=sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a
106+
# via pandas
107+
pytz==2021.1 \
108+
--hash=sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da \
109+
--hash=sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798
110+
# via pandas
111+
six==1.16.0 \
112+
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
113+
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
114+
# via python-dateutil
115+
toml==0.10.2 \
116+
--hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \
117+
--hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f
118+
# via pytest

integration-tests/test_psql_parity.py

+15-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import pandas as pd
18-
import numpy as np
1917
import io
2018
import os
2119
import subprocess
2220
from pathlib import Path
23-
import unittest
21+
22+
import numpy as np
23+
import pandas as pd
24+
import pytest
2425

2526
pg_db, pg_user, pg_host, pg_port = [
2627
os.environ.get(i)
@@ -70,22 +71,16 @@ def generate_csv_from_psql(fname: str):
7071
)
7172

7273

73-
class PsqlParityTest(unittest.TestCase):
74-
def test_parity(self):
75-
root = Path(os.path.dirname(__file__)) / "sqls"
76-
files = set(root.glob("*.sql"))
77-
self.assertEqual(len(files), 14, msg="tests are missed")
78-
for fname in files:
79-
with self.subTest(fname=fname):
80-
datafusion_output = pd.read_csv(
81-
io.BytesIO(generate_csv_from_datafusion(fname))
82-
)
83-
psql_output = pd.read_csv(io.BytesIO(generate_csv_from_psql(fname)))
84-
self.assertTrue(
85-
np.allclose(datafusion_output, psql_output, equal_nan=True),
86-
msg=f"datafusion output=\n{datafusion_output}, psql_output=\n{psql_output}",
87-
)
74+
root = Path(os.path.dirname(__file__)) / "sqls"
75+
test_files = set(root.glob("*.sql"))
76+
8877

78+
class TestPsqlParity:
79+
def test_tests_count(self):
80+
assert len(test_files) == 14, "tests are missed"
8981

90-
if __name__ == "__main__":
91-
unittest.main()
82+
@pytest.mark.parametrize("fname", test_files)
83+
def test_sql_file(self, fname):
84+
datafusion_output = pd.read_csv(io.BytesIO(generate_csv_from_datafusion(fname)))
85+
psql_output = pd.read_csv(io.BytesIO(generate_csv_from_psql(fname)))
86+
np.testing.assert_allclose(datafusion_output, psql_output, equal_nan=True)

0 commit comments

Comments
 (0)