Make utils_test.py more robust.
Tkinter.Tk() requires $DISPLAY to be set or the
testCalculateVNCScreenRatio unittest fails. Replace the call with a set
screenname to avoid that issue.
Bug: None
Test: atest acloud_test (when $DISPLAY is unset)
Change-Id: I94aa13fec9e3071e83a41000bcce7c9cbcef974d
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index cdb18ef..6dab2ef 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -249,6 +249,10 @@
@mock.patch.object(Tkinter.Tk, "winfo_screenheight")
def testCalculateVNCScreenRatio(self, mock_screenheight, mock_screenwidth):
"""Test Calculating the scale ratio of VNC display."""
+ # Tkinter.Tk requires $DISPLAY to be set if the screenName is None so
+ # set screenName to avoid TclError when running this test in a term that
+ # doesn't have $DISPLAY set.
+ mock.patch.object(Tkinter, "Tk", new=Tkinter.Tk(screenName=":0"))
# Get scale-down ratio if screen height is smaller than AVD height.
mock_screenheight.return_value = 800