import os
from testfixtures import tempdir
import unittest
import yaml
from i2ssh.config import Config

FILENAME = '.i2sshrc'

class ConfigTest(unittest.TestCase):

    @tempdir()
    def test_cluster(self, tmpdir):
        cluster_config = {'hosts': ['host1']}
        full_config = {'mycluster': cluster_config}

        tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False))
        config = Config(os.path.join(tmpdir.path, FILENAME))

        self.assertEquals(cluster_config, config.cluster('mycluster'))


import os
from testfixtures import tempdir
import unittest
import yaml
from i2ssh.config import Config

FILENAME = '.i2sshrc'

class ConfigTest(unittest.TestCase):

    @tempdir()
    def test_cluster(self, tmpdir):
        cluster_config = {'hosts': ['host1']}
        full_config = {'mycluster': cluster_config}

        tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False).encode('utf-8'))
        config = Config(os.path.join(tmpdir.path, FILENAME))

        self.assertEquals(cluster_config, config.cluster('mycluster'))


Fix python3 build: Set byte encoding when writing to file.
Fix python3 build: Set byte encoding when writing to file.

  import os
  from testfixtures import tempdir
  import unittest
  import yaml
  from i2ssh.config import Config
  
  FILENAME = '.i2sshrc'
  
  class ConfigTest(unittest.TestCase):
  
      @tempdir()
      def test_cluster(self, tmpdir):
          cluster_config = {'hosts': ['host1']}
          full_config = {'mycluster': cluster_config}
  
-         tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False))
+         tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False).encode('utf-8'))
          config = Config(os.path.join(tmpdir.path, FILENAME))
  
          self.assertEquals(cluster_config, config.cluster('mycluster'))
  
  
Fix python3 build: Set byte encoding when writing to file.
## Code Before:
import os
from testfixtures import tempdir
import unittest
import yaml
from i2ssh.config import Config

FILENAME = '.i2sshrc'

class ConfigTest(unittest.TestCase):

    @tempdir()
    def test_cluster(self, tmpdir):
        cluster_config = {'hosts': ['host1']}
        full_config = {'mycluster': cluster_config}

        tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False))
        config = Config(os.path.join(tmpdir.path, FILENAME))

        self.assertEquals(cluster_config, config.cluster('mycluster'))


## Instruction:
Fix python3 build: Set byte encoding when writing to file.
## Code After:
import os
from testfixtures import tempdir
import unittest
import yaml
from i2ssh.config import Config

FILENAME = '.i2sshrc'

class ConfigTest(unittest.TestCase):

    @tempdir()
    def test_cluster(self, tmpdir):
        cluster_config = {'hosts': ['host1']}
        full_config = {'mycluster': cluster_config}

        tmpdir.write(FILENAME, yaml.dump(full_config, default_flow_style=False).encode('utf-8'))
        config = Config(os.path.join(tmpdir.path, FILENAME))

        self.assertEquals(cluster_config, config.cluster('mycluster'))

