# Path: peru/async_helpers.py
# def run_task(coro):
#     return EVENT_LOOP.run_until_complete(coro)
# 
# Path: peru/compat.py
# def makedirs(path):
#     '''os.makedirs() has an exist_ok param, but it still throws errors when the
#     path exists with non-default permissions. This isn't fixed until 3.4.
#     Pathlib won't be getting an exist_ok param until 3.5.'''
#     path = str(path)  # compatibility with pathlib
#     # Use isdir to avoid silently returning if the path exists but isn't a dir.
#     if not os.path.isdir(path):
#         os.makedirs(path)


import difflib
import functools
import inspect
import io
import os
import stat
import subprocess
import sys
import tempfile
import textwrap
import unittest
import peru.main
from pathlib import Path
from peru.async_helpers import run_task
from peru.compat import makedirs


test_resources = Path(__file__).parent.resolve() / 'resources'

# Colons are a reserved character on Windows, so tests that cover filenames
# with colons need to do something else.
COLON = ':'
if os.name == 'nt':
    COLON = 'COLON_'


def make_synchronous(f):
    '''This lets you turn coroutines into regular functions and call them from
    synchronous code, so for example test methods can be coroutines. It does
    NOT let you call coroutines as regular functions *inside* another
    coroutine. That will raise an "Event loop is running" error.'''

    @functools.wraps(f)
    def wrapper(*args, **kwargs):

# Path: peru/async_helpers.py
# def run_task(coro):
#     return EVENT_LOOP.run_until_complete(coro)
# 
# Path: peru/compat.py
# def makedirs(path):
#     '''os.makedirs() has an exist_ok param, but it still throws errors when the
#     path exists with non-default permissions. This isn't fixed until 3.4.
#     Pathlib won't be getting an exist_ok param until 3.5.'''
#     path = str(path)  # compatibility with pathlib
#     # Use isdir to avoid silently returning if the path exists but isn't a dir.
#     if not os.path.isdir(path):
#         os.makedirs(path)


# Path: tests/shared.py
import difflib
import functools
import inspect
import io
import os
import stat
import subprocess
import sys
import tempfile
import textwrap
import unittest
import peru.main
from pathlib import Path
from peru.async_helpers import run_task
from peru.compat import makedirs



test_resources = Path(__file__).parent.resolve() / 'resources'

# Colons are a reserved character on Windows, so tests that cover filenames
# with colons need to do something else.
COLON = ':'
if os.name == 'nt':
    COLON = 'COLON_'


def make_synchronous(f):
    '''This lets you turn coroutines into regular functions and call them from
    synchronous code, so for example test methods can be coroutines. It does
    NOT let you call coroutines as regular functions *inside* another
    coroutine. That will raise an "Event loop is running" error.'''

    @functools.wraps(f)
    def wrapper(*args, **kwargs):

        return run_task(f(*args, **kwargs))