import os
from subprocess import call
import unittest

from testpath.commands import *

class CommandsTests(unittest.TestCase):
    def test_assert_calls(self):
        initial_path = os.environ['PATH']        
        
        with assert_calls('foobar'):
            call(['foobar'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('foo'):
                pass
        
        # The context manager should clean up $PATH again
        self.assertEqual(os.environ['PATH'], initial_path)
    
    def test_assert_calls_with_args(self):
        with assert_calls('foo', ['bar', 'baz']):
            call(['foo', 'bar', 'baz'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('cheese', ['crackers']):
                call(['cheese', 'biscuits'])
                call(['cheese', 'wine'])

import os
from subprocess import call
import unittest

from testpath.commands import *

class CommandsTests(unittest.TestCase):
    def test_assert_calls(self):
        initial_path = os.environ['PATH']        
        
        with assert_calls('foobar'):
            call(['foobar'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('foo'):
                pass
        
        # The context manager should clean up $PATH again
        self.assertEqual(os.environ['PATH'], initial_path)
    
    def test_assert_calls_with_args(self):
        with assert_calls('foo', ['bar', 'baz']):
            call(['foo', 'bar', 'baz'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('cheese', ['crackers']):
                call(['cheese', 'biscuits'])
                call(['cheese', 'wine'])

    def test_assert_calls_twice(self):
        with assert_calls('git'):
            call(['git'])

        with self.assertRaises(AssertionError):
            with assert_calls('git'):
                pass

Add failing test for gh-5
Add failing test for gh-5

  import os
  from subprocess import call
  import unittest
  
  from testpath.commands import *
  
  class CommandsTests(unittest.TestCase):
      def test_assert_calls(self):
          initial_path = os.environ['PATH']        
          
          with assert_calls('foobar'):
              call(['foobar'])
          
          with self.assertRaises(AssertionError):
              with assert_calls('foo'):
                  pass
          
          # The context manager should clean up $PATH again
          self.assertEqual(os.environ['PATH'], initial_path)
      
      def test_assert_calls_with_args(self):
          with assert_calls('foo', ['bar', 'baz']):
              call(['foo', 'bar', 'baz'])
          
          with self.assertRaises(AssertionError):
              with assert_calls('cheese', ['crackers']):
                  call(['cheese', 'biscuits'])
                  call(['cheese', 'wine'])
  
+     def test_assert_calls_twice(self):
+         with assert_calls('git'):
+             call(['git'])
+ 
+         with self.assertRaises(AssertionError):
+             with assert_calls('git'):
+                 pass
+ 
Add failing test for gh-5
## Code Before:
import os
from subprocess import call
import unittest

from testpath.commands import *

class CommandsTests(unittest.TestCase):
    def test_assert_calls(self):
        initial_path = os.environ['PATH']        
        
        with assert_calls('foobar'):
            call(['foobar'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('foo'):
                pass
        
        # The context manager should clean up $PATH again
        self.assertEqual(os.environ['PATH'], initial_path)
    
    def test_assert_calls_with_args(self):
        with assert_calls('foo', ['bar', 'baz']):
            call(['foo', 'bar', 'baz'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('cheese', ['crackers']):
                call(['cheese', 'biscuits'])
                call(['cheese', 'wine'])

## Instruction:
Add failing test for gh-5
## Code After:
import os
from subprocess import call
import unittest

from testpath.commands import *

class CommandsTests(unittest.TestCase):
    def test_assert_calls(self):
        initial_path = os.environ['PATH']        
        
        with assert_calls('foobar'):
            call(['foobar'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('foo'):
                pass
        
        # The context manager should clean up $PATH again
        self.assertEqual(os.environ['PATH'], initial_path)
    
    def test_assert_calls_with_args(self):
        with assert_calls('foo', ['bar', 'baz']):
            call(['foo', 'bar', 'baz'])
        
        with self.assertRaises(AssertionError):
            with assert_calls('cheese', ['crackers']):
                call(['cheese', 'biscuits'])
                call(['cheese', 'wine'])

    def test_assert_calls_twice(self):
        with assert_calls('git'):
            call(['git'])

        with self.assertRaises(AssertionError):
            with assert_calls('git'):
                pass
