<commit_before>#!/usr/bin/env python3
# vim:ts=4:sw=4:et:

import asyncio
import os
import unittest

import pywatchman_aio
import WatchmanInstance


# Note this does not extend AsyncWatchmanTestCase as it wants to start its
# own Watchman server instances per test.
class TestDeadSocket(unittest.TestCase):
    def test_query_dead_socket(self):
        async def test_core(wminst):
            with await pywatchman_aio.AIOClient.from_socket(
                sockname=wminst.getSockPath()
            ) as client:
                wminst.stop()
                with self.assertRaises(ConnectionResetError):
                    await client.query("version")

        self._async_runner(test_core)

    def test_subscription_dead_socket(self):
        async def test_core(wminst):
            with await pywatchman_aio.AIOClient.from_socket(
                sockname=wminst.getSockPath()
            ) as client:
                root = f"{wminst.base_dir}/work"
                os.makedirs(root)<commit_msg>skip aio dead socket tests on windows (#674)<commit_after>#!/usr/bin/env python3
# vim:ts=4:sw=4:et:

import asyncio
import os
import unittest

import pywatchman_aio
import WatchmanInstance


# Note this does not extend AsyncWatchmanTestCase as it wants to start its
# own Watchman server instances per test.
class TestDeadSocket(unittest.TestCase):
    @unittest.skipIf(os.name == "nt", "not supported on windows")
    def test_query_dead_socket(self):
        async def test_core(wminst):
            with await pywatchman_aio.AIOClient.from_socket(
                sockname=wminst.getSockPath()
            ) as client:
                wminst.stop()
                with self.assertRaises(ConnectionResetError):
                    await client.query("version")

        self._async_runner(test_core)

    @unittest.skipIf(os.name == "nt", "not supported on windows")
    def test_subscription_dead_socket(self):
        async def test_core(wminst):
            with await pywatchman_aio.AIOClient.from_socket(
                sockname=wminst.getSockPath()
            ) as client:
                root = f"{wminst.base_dir}/work"
                os.makedirs(root)
{'fraction_non_alphanumeric': 0.08337171810225702, 'fraction_numerical': 0.004145555043758637, 'mean_word_length': 2.549019607843137, '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': '6517170', 'n_tokens_mistral': 668, 'n_tokens_neox': 640, 'n_words': 146}