<commit_before>import os
import unittest
import shutil

from doppel import copy

this_dir = os.path.abspath(os.path.dirname(__file__))
test_data_dir = os.path.join(this_dir, '..', 'data')
test_stage_dir = os.path.join(this_dir, '..', 'stage')


class TestCopy(unittest.TestCase):
    def setUp(self):
        self.stage = os.path.join(test_stage_dir, 'copy')
        if os.path.exists(self.stage):
            shutil.rmtree(os.path.join(self.stage))
        os.makedirs(self.stage)
        os.chdir(test_data_dir)

    def test_copy_file(self):
        dst = os.path.join(self.stage, 'file.txt')
        copy('file.txt', dst)
        self.assertTrue(os.path.isfile(dst))

    def test_recopy_file(self):
        dst = os.path.join(self.stage, 'file.txt')
        open(dst, 'w').close()
        copy('file.txt', dst)
        self.assertTrue(os.path.isfile(dst))

    def test_copy_empty_dir(self):
        dst = os.path.join(self.stage, 'empty_dir')
        copy('empty_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(os.listdir(dst), [])

    def test_recopy_empty_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        os.mkdir(dst)
        open(os.path.join(dst, 'file.txt'), 'w').close()

        copy('empty_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'file.txt'})

    def test_copy_full_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        copy('full_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'file.txt'})

    def test_recopy_full_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        os.mkdir(dst)
        open(os.path.join(dst, 'existing.txt'), 'w').close()

        copy('full_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'existing.txt', 'file.txt'})<commit_msg>Fix tests (thanks a lot, git!)<commit_after>import os
import unittest
import shutil

from doppel import copy, makedirs, mkdir

this_dir = os.path.abspath(os.path.dirname(__file__))
test_data_dir = os.path.join(this_dir, '..', 'data')
test_stage_dir = os.path.join(this_dir, '..', 'stage')


class TestCopy(unittest.TestCase):
    def setUp(self):
        self.stage = os.path.join(test_stage_dir, 'copy')
        if os.path.exists(self.stage):
            shutil.rmtree(os.path.join(self.stage))
        makedirs(self.stage)
        os.chdir(test_data_dir)

        # Git doesn't store empty directories, so make one.
        mkdir('empty_dir', exist_ok=True)

    def test_copy_file(self):
        dst = os.path.join(self.stage, 'file.txt')
        copy('file.txt', dst)
        self.assertTrue(os.path.isfile(dst))

    def test_recopy_file(self):
        dst = os.path.join(self.stage, 'file.txt')
        open(dst, 'w').close()
        copy('file.txt', dst)
        self.assertTrue(os.path.isfile(dst))

    def test_copy_empty_dir(self):
        dst = os.path.join(self.stage, 'empty_dir')
        copy('empty_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(os.listdir(dst), [])

    def test_recopy_empty_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        mkdir(dst)
        open(os.path.join(dst, 'file.txt'), 'w').close()

        copy('empty_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'file.txt'})

    def test_copy_full_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        copy('full_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'file.txt'})

    def test_recopy_full_dir(self):
        dst = os.path.join(self.stage, 'full_dir')
        mkdir(dst)
        open(os.path.join(dst, 'existing.txt'), 'w').close()

        copy('full_dir', dst)
        self.assertTrue(os.path.isdir(dst))
        self.assertEqual(set(os.listdir(dst)), {'existing.txt', 'file.txt'})
{'fraction_non_alphanumeric': 0.16574724172517552, 'fraction_numerical': 0.0, 'mean_word_length': 2.880350194552529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2813174', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1421, 'n_words': 208}