From 65fee4ceee8f30eb686eb9305e64e856c4cb57d3 Mon Sep 17 00:00:00 2001
From: Ha Manh Dong <donghm@vn.fujitsu.com>
Date: Tue, 17 Jul 2018 10:55:49 +0700
Subject: [PATCH] Switch to use stestr for unit test

According to Openstack summit session [1],
stestr is maintained project to which all Openstack projects should migrate.
So we should switch to stestr.

[1] https://etherpad.openstack.org/p/YVR-python-pti

Change-Id: I4cd261ce5cc4ac7a26fb644eb43c2848f2c26f8b
---
 .gitignore       | 5 ++++-
 .stestr.conf     | 3 +++
 .testr.conf      | 4 ----
 requirements.txt | 2 +-
 tox.ini          | 6 ++++--
 5 files changed, 12 insertions(+), 8 deletions(-)
 create mode 100644 .stestr.conf
 delete mode 100644 .testr.conf

diff --git a/.gitignore b/.gitignore
index b774adf..26cc1ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,7 @@ build
 *.swp
 *.swo
 *.pyc
-.testrepository
\ No newline at end of file
+.stestr/
+
+# Files generated by JetBrains
+.idea/
\ No newline at end of file
diff --git a/.stestr.conf b/.stestr.conf
new file mode 100644
index 0000000..654aae4
--- /dev/null
+++ b/.stestr.conf
@@ -0,0 +1,3 @@
+[DEFAULT]
+test_path=./tests
+top_dir=./
\ No newline at end of file
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100644
index 1641f86..0000000
--- a/.testr.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-[DEFAULT]
-test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
-test_id_option=--load-list $IDFILE
-test_list_option=--list
diff --git a/requirements.txt b/requirements.txt
index d53adb1..2cb81bd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,6 @@ docutils!=0.13.1,>=0.11 # OSI-Approved Open Source, Public Domain
 oslosphinx>=4.7.0  # Apache-2.0
 pbr>=2.0.0,!=2.1.0  # Apache-2.0
 sphinx>=1.6.2
-testrepository>=0.0.18
+stestr>=2.0.0 # Apache-2.0
 testtools>=1.4.0  # MIT
 yasfb>=0.5.1
diff --git a/tox.ini b/tox.ini
index 2d2f6c5..51719be 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,13 +8,15 @@ skipsdist = True
 [testenv]
 basepython = python2.7
 usedevelop = True
-setenv = VIRTUAL_ENV={envdir}
+setenv =
+  VIRTUAL_ENV={envdir}
 install_command = pip install -U {opts} {packages}
 deps = -r{toxinidir}/requirements.txt
 whitelist_externals = find
 commands =
   find . -type f -name "*.py[c|o]" -delete
-  python setup.py testr --slowest --testr-args='{posargs}'
+  stestr run --no-subunit-trace {posargs}
+  stestr slowest
 
 [testenv:venv]
 commands = {posargs}