# Path: segno/cli.py
# _EXT_TO_KW_MAPPING = {}
# def _get_args(func):
# def make_parser():
#     def _convert_scale(val):
# def parse(args):
# def build_config(config, filename=None):
# def make_code(config):
# def main(args=sys.argv[1:]):
#     def __init__(self, *args, **kwargs):
# class _AttrDict(dict):


import os
import tempfile
import pytest
from segno import cli
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2022 -- Lars Heuer
# All rights reserved.
#
# License: BSD License
#
"""\
Tests against issue #84.
<https://github.com/heuer/segno/issues/84>
"""
from __future__ import unicode_literals, absolute_import


def test_issue_84_default_encoding():
    with open(os.path.join(os.path.dirname(__file__), 'issue-84',
                           'issue-84-iso-8859-1.txt'), 'r') as f:
        expected = f.read()
    f = tempfile.NamedTemporaryFile('w', suffix='.txt', delete=False)
    f.close()
    try:
        cli.main(['-o', f.name, 'Müller'])
        with open(f.name, 'r') as f:
            result = f.read()
        assert expected == result
        # Explicit but default encoding

# Path: segno/cli.py
# _EXT_TO_KW_MAPPING = {}
# def _get_args(func):
# def make_parser():
#     def _convert_scale(val):
# def parse(args):
# def build_config(config, filename=None):
# def make_code(config):
# def main(args=sys.argv[1:]):
#     def __init__(self, *args, **kwargs):
# class _AttrDict(dict):


# Path: tests/test_issue84_cli_encoding.py
import os
import tempfile
import pytest
from segno import cli

# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2022 -- Lars Heuer
# All rights reserved.
#
# License: BSD License
#
"""\
Tests against issue #84.
<https://github.com/heuer/segno/issues/84>
"""
from __future__ import unicode_literals, absolute_import


def test_issue_84_default_encoding():
    with open(os.path.join(os.path.dirname(__file__), 'issue-84',
                           'issue-84-iso-8859-1.txt'), 'r') as f:
        expected = f.read()
    f = tempfile.NamedTemporaryFile('w', suffix='.txt', delete=False)
    f.close()
    try:
        cli.main(['-o', f.name, 'Müller'])
        with open(f.name, 'r') as f:
            result = f.read()
        assert expected == result
        # Explicit but default encoding

        cli.main(['-o', f.name, '--encoding', 'iso-8859-1', 'Müller'])