old_contents: #!/usr/bin/env python
  # Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.
  
  import os
  import mock
  import stat
  import tempfile
  
  from . import resize_image as _
  
  class TestOutputValidation():
      def test_no_filename(self):
          assert not _.validate_output_file(None), 'validation should not pass on None'
  
      @mock.patch('os.access')
      def test_not_writable(self, mock_access):
          mock_access.return_value = False
          with tempfile.NamedTemporaryFile('r') as f:
              assert not _.validate_output_file(f.name), 'validation should not pass on unwritable file'
  
      def test_local(self):
          with tempfile.NamedTemporaryFile('r', dir='.') as f:
              name = os.path.basename(f.name)
              assert _.validate_output_file(name), 'validation should pass on temporary file'
  
      def test_normal(self):
          with tempfile.NamedTemporaryFile('r') as f:
              assert _.validate_output_file(f.name), 'validation should pass on temporary file'
  
  
  class TestInputValidation():
      def test_does_not_exist(self):
          temp_dir = tempfile.mkdtemp()
  
          missing_filename = os.path.join(temp_dir, 'does_not_exist.png')
          assert not os.path.exists(missing_filename), '"%s" exists in directory, but shouldn\'t' % missing_filename
          assert not _.validate_input_file(missing_filename), 'validation should not pass on missing file "%s"' % missing_filename
  
          os.rmdir(temp_dir)
  
      @mock.patch('os.access')
      def test_unreadable_file(self, mock_access):
          mock_access.return_value = False
          with tempfile.NamedTemporaryFile('r') as f:
              assert not _.validate_input_file(f.name), 'validation should not pass on unreadable file'
  
  
  class TestRangeValidation():
      def test_number_none_and_not_allowed(self):
          assert not _.validate_range(None, allow_none=False), 'number=None should not be allowed with allow_none=False'
  
      def test_number_not_float_compatible(self):
          value = 'a'
          assert not _.validate_range(value), 'number=%s should not be accepted' % value
  
      def test_number_below_min(self):
          assert not _.validate_range(0, min_value=1), 'validation should not pass with number < min_value'
  
      def test_number_above_max(self):
          assert not _.validate_range(2, max_value=1), 'validation should not pass with number > max_value'
  
      def test_range(self):
          assert _.validate_range(5, min_value=0, max_value=255), 'validation should pass with 5 in range (0, 255)'
  
new_contents: #!/usr/bin/env python
  # Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.
  
  import os
  import mock
  import stat
  import tempfile
  
  from . import resize_image as _
  
  class TestOutputValidation():
      def test_no_filename(self):
          assert not _.validate_output_file(None), 'validation should not pass on None'
  
      @mock.patch('os.access')
      def test_not_writable(self, mock_access):
          mock_access.return_value = False
          with tempfile.NamedTemporaryFile('r') as f:
              assert not _.validate_output_file(f.name), 'validation should not pass on unwritable file'
  
      def test_local(self):
          with tempfile.NamedTemporaryFile('r', dir='.') as f:
              name = os.path.basename(f.name)
              assert _.validate_output_file(name), 'validation should pass on temporary file'
  
      def test_normal(self):
          with tempfile.NamedTemporaryFile('r') as f:
              assert _.validate_output_file(f.name), 'validation should pass on temporary file'
  
  
  class TestInputValidation():
      def test_does_not_exist(self):
          assert not _.validate_input_file(''), 'validation should not pass on missing file'
  
      @mock.patch('os.access')
      def test_unreadable_file(self, mock_access):
          mock_access.return_value = False
          with tempfile.NamedTemporaryFile('r') as f:
              assert not _.validate_input_file(f.name), 'validation should not pass on unreadable file'
  
  
  class TestRangeValidation():
      def test_number_none_and_not_allowed(self):
          assert not _.validate_range(None, allow_none=False), 'number=None should not be allowed with allow_none=False'
  
      def test_number_not_float_compatible(self):
          value = 'a'
          assert not _.validate_range(value), 'number=%s should not be accepted' % value
  
      def test_number_below_min(self):
          assert not _.validate_range(0, min_value=1), 'validation should not pass with number < min_value'
  
      def test_number_above_max(self):
          assert not _.validate_range(2, max_value=1), 'validation should not pass with number > max_value'
  
      def test_range(self):
          assert _.validate_range(5, min_value=0, max_value=255), 'validation should pass with 5 in range (0, 255)'
  
subject: Simplify missing file test in test_resize_image