import os
from hycc.util import hycc_main


def clean():
    for path in os.listdir("tests/resources"):
        if path not in ["hello.hy", "__init__.py"]:
            os.remove(os.path.join("tests/resources", path))


def test_build_executable():
    hycc_main("tests/resources/hello.hy".split())
    assert os.path.exists("tests/resources/hello")
    clean()


def test_shared_library():
    hycc_main("tests/resources/hello.hy --shared".split())
    from tests.resources.hello import hello
    assert hello() == "hello"
    clean()

import os
from hycc.util import hycc_main


def clean():
    for path in os.listdir("tests/resources"):
        if path not in ["hello.hy", "__init__.py"]:
            path = os.path.join("tests/resources", path)
            if os.path.isdir(path):
                os.rmdir(path)
            else:
                os.remove(path)


def test_build_executable():
    hycc_main("tests/resources/hello.hy".split())
    assert os.path.exists("tests/resources/hello")
    clean()


def test_shared_library():
    hycc_main("tests/resources/hello.hy --shared".split())
    from tests.resources.hello import hello
    assert hello() == "hello"
    clean()

Fix bug; os.remove cannot remove directories
Fix bug; os.remove cannot remove directories

  import os
  from hycc.util import hycc_main
  
  
  def clean():
      for path in os.listdir("tests/resources"):
          if path not in ["hello.hy", "__init__.py"]:
-             os.remove(os.path.join("tests/resources", path))
+             path = os.path.join("tests/resources", path)
+             if os.path.isdir(path):
+                 os.rmdir(path)
+             else:
+                 os.remove(path)
  
  
  def test_build_executable():
      hycc_main("tests/resources/hello.hy".split())
      assert os.path.exists("tests/resources/hello")
      clean()
  
  
  def test_shared_library():
      hycc_main("tests/resources/hello.hy --shared".split())
      from tests.resources.hello import hello
      assert hello() == "hello"
      clean()
  
Fix bug; os.remove cannot remove directories
## Code Before:
import os
from hycc.util import hycc_main


def clean():
    for path in os.listdir("tests/resources"):
        if path not in ["hello.hy", "__init__.py"]:
            os.remove(os.path.join("tests/resources", path))


def test_build_executable():
    hycc_main("tests/resources/hello.hy".split())
    assert os.path.exists("tests/resources/hello")
    clean()


def test_shared_library():
    hycc_main("tests/resources/hello.hy --shared".split())
    from tests.resources.hello import hello
    assert hello() == "hello"
    clean()

## Instruction:
Fix bug; os.remove cannot remove directories
## Code After:
import os
from hycc.util import hycc_main


def clean():
    for path in os.listdir("tests/resources"):
        if path not in ["hello.hy", "__init__.py"]:
            path = os.path.join("tests/resources", path)
            if os.path.isdir(path):
                os.rmdir(path)
            else:
                os.remove(path)


def test_build_executable():
    hycc_main("tests/resources/hello.hy".split())
    assert os.path.exists("tests/resources/hello")
    clean()


def test_shared_library():
    hycc_main("tests/resources/hello.hy --shared".split())
    from tests.resources.hello import hello
    assert hello() == "hello"
    clean()
