-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Getting pytest/pluggy/colorama issues while running test file #3335
Comments
GitMate.io thinks possibly related issues are #2258 (Unicode issues with pytest.fail), #471 (pytest keeps running deleted tests), #1563 (All pytest tests skipped), #1591 (pytest-xdist fails when running same tests several times), and #2723 (Pytest not detecting local .ini file when running specific part of test). |
how to resolve this? Please help! |
When I run multipletimes then tests are running 1 time out of 10 times, but all the tests are failing locally even though those are passing in jenkins job. Rest the time i get same error which i have mentioned in my thread.... Getting pytest/pluggy/colorama issues while running test file #3335 |
@rajatkmehta hard to tell what might be the problem, might be a broken |
I am trying to run the script in which need to make connection from database(CONN1 and CONN2), execute queries(SQL 1 and SQL2), fetch data and compare them. But getting errors like as follows.... |
Sorry @rajatkmehta your last message doesn't seem related to pytest at all. Please provide enough information, preferably properly formatted, otherwise it is very hard for us to try to help you. |
Using script: @pytest.mark.compare_expected_changes_tolerance
def test_expected_changes_tolerance(test_data, comparator):
"""Comparing difference between two sql returning numeric values with expected tolerance
Note: SQL should not contain nested values - they should be flattened.
- Only two columns are allowed in select statement where count is the second value
- Output of queries is generated as key:value pair.
Result of numeric fields is matched against each other with expected tolerance
"""
comparator.global_tolerance = None
comparator.tolerance_lookup = None
print "*"*20
try:
# Load test parameters
# convert test_params_json string into json
test_params_json = {}
if test_data.get("test_params_json"):
test_params_json = json.loads(test_data["test_params_json"])
# if data_sample_sql is present, then get data sample from second connection (expected values)
if test_data.get("data_sample_sql", None):
test_params_json = add_data_sample_to_test_params_json(test_data, test_params_json)
# connect to the first connection and get results from first sql
# get connection
test_conn1_dtl = get_conn_details(test_data["conn1"])
conn1 = globals()["%s_conn" % test_conn1_dtl["conn_type"]](test_conn1_dtl)
# generate sql
sql1 = test_data["sql1"].format(**test_params_json)
# execute first sql statement
actual_json = fetch_records(conn1, sql1, "use_first_column_as_headers")
# read JSON file that compares results
test_conn2_dtl = get_conn_details(test_data["conn2"])
conn2 = globals()["%s_conn" % test_conn2_dtl["conn_type"]](test_conn2_dtl)
# generate sql
sql2 = test_data["sql2"].format(**test_params_json)
# execute first sql statement
expected_json = fetch_records(conn2, sql2, "use_first_column_as_headers")
# make sure none of the lists are empty
if not (actual_json and expected_json):
raise ValueError("One of the inputs returned no rows")
if test_data.get("global_tolerance"):
comparator.global_tolerance = float(test_data["global_tolerance"])
if test_data.get("values_tolerance_dict"):
comparator.tolerance_lookup = json.loads(test_data["values_tolerance_dict"])
# compare data between actual_json and expected_json
# print "-"*20
# print "actual", json.dumps(actual_json, indent=2)
# print "expected", json.dumps(expected_json, indent=2)
# print "tolerance", str(comparator.global_tolerance)
# print "tolerance_lookup", json.dumps(comparator.tolerance_lookup)
# print "-"*20
comparator.compare_json(actual_json, expected_json)
except Exception as e:
comparator.increment_exception_fail(e)
finally:
comparator.global_tolerance = None
comparator.tolerance_lookup = None
comparator.print_results()
comparator.assert_pass() To run this script using command from terminal:
|
(@rajatkmehta I formatted your post myself, please take a look at the GH Markdown Help). Did you try running |
Thanks for formatting my script! |
Can you please post the full output when you run with |
|
(Please edit your message and format it correctly, otherwise it is very hard to read the traceback, thanks!) |
is the format okay now? |
Unfortunately no 😞 |
The text was updated successfully, but these errors were encountered: