# Path: pyDEA/core/utils/dea_utils.py
# def format_data(data):
#     ''' Formats floating point number to 6 digits.
# 
#         Args:
#             data (double): data that must be formatted
# 
#         Returns:
#             str: formatted data.
# 
#         Example:
#             >>> format_data(1.222222222222222)
#             >>> '1.222222'
#             >>> format_data('str')
#             >>> 'str'
#             >>> format_data(0.123456789)
#             >>> '0.123457'
#             >>> format_data('0.05')
#             >>> '0.050000'
#     '''
#     try:
#         float_data = float(data)
#     except ValueError:
#         return str(data)
#     else:
#         return '%.6f' % float_data


import os
import shutil
from pyDEA.core.data_processing.solution_text_writer import TxtWriter, SolutionTextWriter
from pyDEA.core.utils.dea_utils import format_data
        name = 'name{0}'.format(i + 1)
        txt_writer.tab_writers[i][1].name = name
        names.append(name)
    # name does not matter, it is picked up from tab_writers
    txt_writer.save('haha')
    for name in names:
        assert os.path.exists(os.path.join(
            folder_name, '{0}.csv'.format(name))) is True
    shutil.rmtree(folder_name)


def test_existing_folder():
    folder_name = os.path.join('tests', 'tmp_test_solution_writer3')
    txt_writer = TxtWriter(folder_name)
    txt_writer = TxtWriter(folder_name)  # second call should not fail,
    # and should refer to the same folder
    assert os.path.exists(folder_name)
    shutil.rmtree(folder_name)


def test_write():
    saved_text = SimpleWriter()
    writer = SolutionTextWriter(';', saved_text.write)
    writer.write(0, 0, 'text')
    assert len(saved_text.text) == 2
    assert saved_text.text[0] == '\n'
    assert saved_text.text[1] == 'text'
    writer.write(0, 1, '1.5')
    assert len(saved_text.text) == 4
    assert saved_text.text[2] == ';'

# Path: pyDEA/core/utils/dea_utils.py
# def format_data(data):
#     ''' Formats floating point number to 6 digits.
# 
#         Args:
#             data (double): data that must be formatted
# 
#         Returns:
#             str: formatted data.
# 
#         Example:
#             >>> format_data(1.222222222222222)
#             >>> '1.222222'
#             >>> format_data('str')
#             >>> 'str'
#             >>> format_data(0.123456789)
#             >>> '0.123457'
#             >>> format_data('0.05')
#             >>> '0.050000'
#     '''
#     try:
#         float_data = float(data)
#     except ValueError:
#         return str(data)
#     else:
#         return '%.6f' % float_data


# Path: tests/test_solution_text_writer.py
import os
import shutil
from pyDEA.core.data_processing.solution_text_writer import TxtWriter, SolutionTextWriter
from pyDEA.core.utils.dea_utils import format_data

        name = 'name{0}'.format(i + 1)
        txt_writer.tab_writers[i][1].name = name
        names.append(name)
    # name does not matter, it is picked up from tab_writers
    txt_writer.save('haha')
    for name in names:
        assert os.path.exists(os.path.join(
            folder_name, '{0}.csv'.format(name))) is True
    shutil.rmtree(folder_name)


def test_existing_folder():
    folder_name = os.path.join('tests', 'tmp_test_solution_writer3')
    txt_writer = TxtWriter(folder_name)
    txt_writer = TxtWriter(folder_name)  # second call should not fail,
    # and should refer to the same folder
    assert os.path.exists(folder_name)
    shutil.rmtree(folder_name)


def test_write():
    saved_text = SimpleWriter()
    writer = SolutionTextWriter(';', saved_text.write)
    writer.write(0, 0, 'text')
    assert len(saved_text.text) == 2
    assert saved_text.text[0] == '\n'
    assert saved_text.text[1] == 'text'
    writer.write(0, 1, '1.5')
    assert len(saved_text.text) == 4
    assert saved_text.text[2] == ';'

    assert saved_text.text[3] == format_data('1.5')