import os
import unittest

import transpiler

class TestTranspiler:

    def test_transpiler_creates_files_without_format(self):
        transpiler.main(["--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

    def test_transpiler_creates_files_with_format(self):
        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

import os
import unittest

import transpiler

class TestTranspiler:

    def test_transpiler_creates_files_without_format(self):
        try:
            os.remove("/tmp/auto_functions.cpp")
            os.remove("/tmp/auto_functions.h")
        except FileNotFoundError:
            pass

        transpiler.main(["--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

    def test_transpiler_creates_files_with_format(self):
        try:
            os.remove("/tmp/auto_functions.cpp")
            os.remove("/tmp/auto_functions.h")
        except FileNotFoundError:
            pass

        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

Make transpiler test remove files if they already exist
Make transpiler test remove files if they already exist

  import os
  import unittest
  
  import transpiler
  
  class TestTranspiler:
  
      def test_transpiler_creates_files_without_format(self):
+         try:
+             os.remove("/tmp/auto_functions.cpp")
+             os.remove("/tmp/auto_functions.h")
+         except FileNotFoundError:
+             pass
+ 
          transpiler.main(["--output-dir", "/tmp"])
  
          assert os.path.isfile("/tmp/auto_functions.cpp")
          assert os.path.isfile("/tmp/auto_functions.h")
  
      def test_transpiler_creates_files_with_format(self):
+         try:
+             os.remove("/tmp/auto_functions.cpp")
+             os.remove("/tmp/auto_functions.h")
+         except FileNotFoundError:
+             pass
+ 
          transpiler.main(["--format", "--output-dir", "/tmp"])
  
          assert os.path.isfile("/tmp/auto_functions.cpp")
          assert os.path.isfile("/tmp/auto_functions.h")
  
Make transpiler test remove files if they already exist
## Code Before:
import os
import unittest

import transpiler

class TestTranspiler:

    def test_transpiler_creates_files_without_format(self):
        transpiler.main(["--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

    def test_transpiler_creates_files_with_format(self):
        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

## Instruction:
Make transpiler test remove files if they already exist
## Code After:
import os
import unittest

import transpiler

class TestTranspiler:

    def test_transpiler_creates_files_without_format(self):
        try:
            os.remove("/tmp/auto_functions.cpp")
            os.remove("/tmp/auto_functions.h")
        except FileNotFoundError:
            pass

        transpiler.main(["--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")

    def test_transpiler_creates_files_with_format(self):
        try:
            os.remove("/tmp/auto_functions.cpp")
            os.remove("/tmp/auto_functions.h")
        except FileNotFoundError:
            pass

        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
