old_contents: # Import python libs
  import sys
  
  # Import salt libs
  from saltunittest import TestLoader, TextTestRunner
  import integration
  from integration import TestDaemon
  
  
  class MatchTest(integration.ShellCase):
      '''
      Test salt matchers
      '''
      def test_list(self):
          '''
          test salt -L matcher
          '''
          data = self.run_salt('-L minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('-L minion,sub_minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
  
      def test_glob(self):
          '''
          test salt glob matcher
          '''
          data = self.run_salt('minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('"*" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
  
      def test_regex(self):
          '''
          test salt regex matcher
          '''
          data = self.run_salt('-E "^minion$" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('-E ".*" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
              
  
  if __name__ == "__main__":
      loader = TestLoader()
      tests = loader.loadTestsFromTestCase(KeyTest)
      print('Setting up Salt daemons to execute tests')
      with TestDaemon():
          runner = TextTestRunner(verbosity=1).run(tests)
          sys.exit(runner.wasSuccessful())
  
new_contents: # Import python libs
  import sys
  
  # Import salt libs
  from saltunittest import TestLoader, TextTestRunner
  import integration
  from integration import TestDaemon
  
  
  class MatchTest(integration.ShellCase):
      '''
      Test salt matchers
      '''
      def test_list(self):
          '''
          test salt -L matcher
          '''
          data = self.run_salt('-L minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('-L minion,sub_minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
  
      def test_glob(self):
          '''
          test salt glob matcher
          '''
          data = self.run_salt('minion test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('"*" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
  
      def test_regex(self):
          '''
          test salt regex matcher
          '''
          data = self.run_salt('-E "^minion$" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('-E ".*" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertIn('sub_minion', data)
  
      def test_grain(self):
          '''
          test salt grain matcher
          '''
          data = self.run_salt('-t 1 -G "test_grain:cheese" test.ping')
          data = '\n'.join(data)
          self.assertIn('minion', data)
          self.assertNotIn('sub_minion', data)
          data = self.run_salt('-G "test_grain:spam" test.ping')
          data = '\n'.join(data)
          self.assertIn('sub_minion', data)
          self.assertNotIn('minion', data.replace('sub_minion', 'stub'))
              
  
  if __name__ == "__main__":
      loader = TestLoader()
      tests = loader.loadTestsFromTestCase(KeyTest)
      print('Setting up Salt daemons to execute tests')
      with TestDaemon():
          runner = TextTestRunner(verbosity=1).run(tests)
          sys.exit(runner.wasSuccessful())
  
subject: Add grain matcher test