Add Python version to `rbt --version` output

Review Request #10917 — Created Feb. 25, 2020 and updated

xiaole2
RBTools
master
rbtools

Add Python version to rbt --version output.

sys.version has full python version value. The output is
Python 2.7.17 (default, Jan 10 2020, 00:33:00) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]

and sys.version_info is a key=value pair tuple.
sys.version_info(major=2, minor=7, micro=17, releaselevel='final', serial=0)

and sys.version_info[:3] will get the first 3 keys' values into a tuple.
The output is (2, 7, 17)

To format the version for python such as x.x.x, I get each digit in the tuple.

Tested in terminal in reviewboard-dev virtual env and reviewboard-dev-rbt for python 2 and 3.
and reviewboard-4.0 virtual envs and reviewboard-4.0-rbt for python 2 and 3.

Create TestCase and pass successfully using ./tests/runtests.py rbtools.commands.tests.test_main and ./tests/runtests.py rbtools.commands.tests.test_main:VersionCommandTests. Test number is #246

Summary Author
add test case
XiaoleZ
remove comma
XiaoleZ
add python version
XiaoleZ
python styling
XiaoleZ
remove trailing space
XiaoleZ
Loading file attachments...

Description From Last Updated

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E221 multiple spaces before operator

reviewbotreviewbot

E126 continuation line over-indented for hanging indent

reviewbotreviewbot

E203 whitespace before ','

reviewbotreviewbot

E231 missing whitespace after ','

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot
kpatenio
  1. Looks good!

    It would be nice to see some unit tests, especially for different python versions? You can add the tests to a test file I made called test_main.py in rbtools/commands/tests.

  2. 
      
xiaole2
Review request changed

Change Summary:

Add test case for rbt --version command

Testing Done:

   

Tested in terminal in reviewboard-dev virtual env and reviewboard-dev-rbt for python 2 and 3.

    and reviewboard-4.0 virtual envs and reviewboard-4.0-rbt for python 2 and 3.

  +
  +

Create TestCase and pass successfully using ./tests/runtests.py rbtools.commands.tests.test_main and ./tests/runtests.py rbtools.commands.tests.test_main:VersionCommandTests. Test number is #246

Commits:

Summary Author
-
add python version
XiaoleZ
+
add test case
XiaoleZ
+
add python version
XiaoleZ
+
remove trailing space
XiaoleZ

Diff:

Revision 2 (+74 -4)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

xiaole2
kpatenio
  1. 
      
  2. rbtools/commands/tests/test_main.py (Diff revision 3)
     
     

    Very minor change. Would you mind removing the last comma inside the round brackets?

    Otherwise, everything looks good to me.

  3. 
      
xiaole2
Review request changed

Change Summary:

remove comma based on Katherine's feedback

Commits:

Summary Author
-
add test case
XiaoleZ
-
add python version
XiaoleZ
-
python styling
XiaoleZ
-
remove trailing space
XiaoleZ
+
add test case
XiaoleZ
+
remove comma
XiaoleZ
+
add python version
XiaoleZ
+
python styling
XiaoleZ
+
remove trailing space
XiaoleZ

Diff:

Revision 4 (+82 -12)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
kpatenio
  1. Ship It!
  2. 
      
Loading...