forked from nvaccess/nvda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
winVersion.WinVersion: add unit test cases. Re nvaccess#11837.
Add unit tests for the following: * winVersion.getWinVer (compared against what Python returns through sys.getwindowsversion) * Convert a string representation of a Windows release to WinVersion class instance * See if a specific major.minor.build is returned for a given release
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#A part of NonVisual Desktop Access (NVDA) | ||
#This file is covered by the GNU General Public License. | ||
#See the file COPYING for more details. | ||
#Copyright (C) 2020 NV Access Limited, Joseph Lee | ||
|
||
"""Unit tests for the Windows version module.""" | ||
|
||
import unittest | ||
import sys | ||
import winVersion | ||
|
||
class TestWinVersion(unittest.TestCase): | ||
|
||
def test_getWinVer(self): | ||
# Test a 3-tuple consisting of version major, minor, build. | ||
# sys.getwindowsversion() internally returns a named tuple, so comparing tuples is possible. | ||
currentWinVer = winVersion.getWinVer() | ||
winVerPython = sys.getwindowsversion() | ||
self.assertTupleEqual( | ||
(currentWinVer.major, currentWinVer.minor, currentWinVer.build), | ||
winVerPython[:3] | ||
) | ||
|
||
def test_specificWinVer(self): | ||
# Try detecting Windows 8.1 or later. | ||
win81 = winVersion.WinVersion(release="8.1") | ||
self.assertTupleEqual( | ||
(win81.major, win81.minor, win81.build), | ||
(6, 3, 9600) | ||
) | ||
|
||
def test_getWinVerFromVersionText(self): | ||
winTenInitial = winVersion.getWinVerFromVersionText("10.0.10240") | ||
self.assertTupleEqual( | ||
(winTenInitial.major, winTenInitial.minor, winTenInitial.build), | ||
(10, 0, 10240) | ||
) |