From e3511392c645fa40fa5836b5f06da48e606f9f80 Mon Sep 17 00:00:00 2001 From: Reedip Banerjee Date: Thu, 3 Dec 2015 11:31:05 +0530 Subject: [PATCH] Delete python bytecode before every test run Because python creates pyc/pyo files during tox runs, certain changes in the tree, like deletes of files, or switching branches, can create spurious errors. This patch removes these unrequired files when tox starts execution, along with the __pycache__ folder for py3* compilation. Change-Id: Iea5f19ab8a4d56dedaa8c3a3950af041d3ff5b9f Closes-Bug: #1368661 --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 377be25..d2edf9d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,10 @@ usedevelop = True install_command = pip install -U {opts} {packages} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = ostestr --regex '{posargs}' +commands = find . -type f -name "*.py[c|o]" -delete + find . -type d -name "__pycache__" -delete + ostestr --regex '{posargs}' +whitelist_externals = find [tox:jenkins] sitepackages = True