Home | History | Annotate | Download | only in android
      1 #! /usr/bin/env python
      2 # Copyright 2016 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 import os
      7 import tempfile
      8 import unittest
      9 
     10 from devil.android import device_blacklist
     11 
     12 
     13 class DeviceBlacklistTest(unittest.TestCase):
     14 
     15   def testBlacklistFileDoesNotExist(self):
     16     with tempfile.NamedTemporaryFile() as blacklist_file:
     17       # Allow the temporary file to be deleted.
     18       pass
     19 
     20     test_blacklist = device_blacklist.Blacklist(blacklist_file.name)
     21     self.assertEquals({}, test_blacklist.Read())
     22 
     23   def testBlacklistFileIsEmpty(self):
     24     try:
     25       with tempfile.NamedTemporaryFile(delete=False) as blacklist_file:
     26         # Allow the temporary file to be closed.
     27         pass
     28 
     29       test_blacklist = device_blacklist.Blacklist(blacklist_file.name)
     30       self.assertEquals({}, test_blacklist.Read())
     31 
     32     finally:
     33       if os.path.exists(blacklist_file.name):
     34         os.remove(blacklist_file.name)
     35 
     36 
     37 if __name__ == '__main__':
     38   unittest.main()
     39